diff --git a/lists/copypastas.txt b/lists/copypastas.txt index 1342eb3..d8f3589 100644 --- a/lists/copypastas.txt +++ b/lists/copypastas.txt @@ -9,7 +9,7 @@ Cooldog || ╰━▅╮ && ╰╮ && ┳━━╯ && ╰┳╯ Dog || ╰┳┳┳╯ && ▔╰━╯ && ╱╲╱╲▏ Memecat || Λ_Λ && ( 'ㅅ' ) && > ⌒ヽ -"Read or you die" || Carry on reading && Once there was && Now every week && send this to && break this chain +"Read or you die" || Carry on reading && Once there was && Now every week && send this to && copy and paste Jake Paul || Jake Paul on a tower about to jump && copy and paste && discord server "Tag you're it" || funny you opened this because && over the next && first you have && send it to && break the chain diff --git a/src/main/java/com/jagrosh/vortex/Vortex.java b/src/main/java/com/jagrosh/vortex/Vortex.java index f2db7ca..534c918 100644 --- a/src/main/java/com/jagrosh/vortex/Vortex.java +++ b/src/main/java/com/jagrosh/vortex/Vortex.java @@ -144,6 +144,7 @@ // Automoderation new AntiinviteCmd(this), new AnticopypastaCmd(this), + new AntieveryoneCmd(this), new AntirefCmd(this), new MaxlinesCmd(this), new MaxmentionsCmd(this), diff --git a/src/main/java/com/jagrosh/vortex/automod/AutoMod.java b/src/main/java/com/jagrosh/vortex/automod/AutoMod.java index 458fb64..2e6b6c3 100644 --- a/src/main/java/com/jagrosh/vortex/automod/AutoMod.java +++ b/src/main/java/com/jagrosh/vortex/automod/AutoMod.java @@ -362,6 +362,17 @@ } } + if(settings.everyoneStrikes > 0 && preventSpam && !message.getMember().hasPermission(message.getTextChannel(), Permission.MESSAGE_MENTION_EVERYONE)) + { + if(message.getContentRaw().contains("@everyone") || message.getContentRaw().contains("@here") + || message.getMentionedRoles().stream().anyMatch(role -> role.getName().equalsIgnoreCase("everyone") || role.getName().equalsIgnoreCase("here"))) + { + strikeTotal += settings.everyoneStrikes; + reason.append(", ").append("Attempted @\u0435veryone/here"); + shouldDelete = true; + } + } + // anti-invite if(settings.inviteStrikes > 0 && preventInvites) { diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/AnticopypastaCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/AnticopypastaCmd.java index 523a735..aa65ceb 100644 --- a/src/main/java/com/jagrosh/vortex/commands/automod/AnticopypastaCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/automod/AnticopypastaCmd.java @@ -1,7 +1,17 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 2018 John Grosh (john.a.grosh@gmail.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.jagrosh.vortex.commands.automod; diff --git a/src/main/java/com/jagrosh/vortex/commands/automod/AntieveryoneCmd.java b/src/main/java/com/jagrosh/vortex/commands/automod/AntieveryoneCmd.java new file mode 100644 index 0000000..29c59b2 --- /dev/null +++ b/src/main/java/com/jagrosh/vortex/commands/automod/AntieveryoneCmd.java @@ -0,0 +1,79 @@ +/* + * Copyright 2018 John Grosh (john.a.grosh@gmail.com). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.jagrosh.vortex.commands.automod; + +import com.jagrosh.jdautilities.command.Command; +import com.jagrosh.jdautilities.command.CommandEvent; +import net.dv8tion.jda.core.Permission; +import com.jagrosh.vortex.Vortex; +import com.jagrosh.vortex.database.managers.AutomodManager; +import com.jagrosh.vortex.database.managers.PunishmentManager; + +/** + * + * @author John Grosh (john.a.grosh@gmail.com) + */ +public class AntieveryoneCmd extends Command +{ + private final Vortex vortex; + + public AntieveryoneCmd(Vortex vortex) + { + this.vortex = vortex; + this.name = "antieveryone"; + this.guildOnly = true; + this.aliases = new String[]{"antiateveryone", "anti-everyone", "anti-ateveryone"}; + this.category = new Category("AutoMod"); + this.arguments = ""; + this.help = "sets strikes for failed @\u0435veryone/here attempts"; + this.userPermissions = new Permission[]{Permission.MANAGE_SERVER}; + } + + @Override + protected void execute(CommandEvent event) + { + if(event.getArgs().isEmpty()) + { + event.replyError("Please provide a number of strikes!"); + return; + } + int numstrikes; + try + { + numstrikes = Integer.parseInt(event.getArgs()); + } + catch(NumberFormatException ex) + { + if(event.getArgs().equalsIgnoreCase("none") || event.getArgs().equalsIgnoreCase("off")) + numstrikes = 0; + else + { + event.replyError("`"+event.getArgs()+"` is not a valid integer!"); + return; + } + } + if(numstrikes<0 || numstrikes>AutomodManager.MAX_STRIKES) + { + event.replyError("The number of strikes must be between 0 and "+AutomodManager.MAX_STRIKES); + return; + } + vortex.getDatabase().automod.setEveryoneStrikes(event.getGuild(), numstrikes); + boolean also = vortex.getDatabase().actions.useDefaultSettings(event.getGuild()); + event.replySuccess("Users will now receive `"+numstrikes+"` strikes for attempting to ping @\u0435veryone/here. " + + "This also considers pingable roles called 'everyone' and 'here'. This will not affect users that actually " + + "have permission to ping everyone."+(also ? PunishmentManager.DEFAULT_SETUP_MESSAGE : "")); + } +} diff --git a/src/main/java/com/jagrosh/vortex/database/managers/AutomodManager.java b/src/main/java/com/jagrosh/vortex/database/managers/AutomodManager.java index 1b06221..17cbe24 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/AutomodManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/AutomodManager.java @@ -51,6 +51,7 @@ public final static SQLColumn INVITE_STRIKES = new IntegerColumn("INVITE_STRIKES", false, 0); public final static SQLColumn REF_STRIKES = new IntegerColumn("REF_STRIKES", false, 0); public final static SQLColumn COPYPASTA_STRIKES = new IntegerColumn("COPYPASTA_STRIKES", false, 0); + public final static SQLColumn EVERYONE_STRIKES = new IntegerColumn("EVERYONE_STRIKES", false, 0); public final static SQLColumn DUPE_STRIKES = new IntegerColumn("DUPE_STRIKES", false, 0); public final static SQLColumn DUPE_DELETE_THRESH = new IntegerColumn("DUPE_DELETE_THRESH", false, 0); @@ -95,10 +96,11 @@ ? "Disabled\n\n" : "Max User Mentions: " + (settings.maxMentions==0 ? "None\n" : "`" + settings.maxMentions + "`\n") + "Max Role Mentions: " + (settings.maxRoleMentions==0 ? "None\n\n" : "`" + settings.maxRoleMentions + "`\n\n")) - + "__Spam Prevention__\n" + (settings.maxLines==0 && settings.copypastaStrikes==0 + + "__Spam Prevention__\n" + (settings.maxLines==0 && settings.copypastaStrikes==0 && settings.everyoneStrikes==0 ? "Disabled\n\n" : "Max Lines / Message: "+(settings.maxLines==0 ? "Disabled\n" : "`"+settings.maxLines+"`\n") + - "Copypasta: `" + settings.copypastaStrikes + " " + Action.STRIKE.getEmoji() + "`\n\n") + "Copypasta: `" + settings.copypastaStrikes + " " + Action.STRIKE.getEmoji() + "`\n" + + "Attempted @\u0435veryone: `" + settings.everyoneStrikes + " " + Action.STRIKE.getEmoji() + "`\n\n") + "__Miscellaneous__\n" + "Auto AntiRaid: " + (settings.useAutoRaidMode() ? "`" + settings.raidmodeNumber + "` joins/`" + settings.raidmodeTime + "`s\n" @@ -296,6 +298,26 @@ }); } + public void setEveryoneStrikes(Guild guild, int strikes) + { + invalidateCache(guild); + readWrite(selectAll(GUILD_ID.is(guild.getIdLong())), rs -> + { + if(rs.next()) + { + EVERYONE_STRIKES.updateValue(rs, strikes); + rs.updateRow(); + } + else + { + rs.moveToInsertRow(); + GUILD_ID.updateValue(rs, guild.getIdLong()); + EVERYONE_STRIKES.updateValue(rs, strikes); + rs.insertRow(); + } + }); + } + public void setDupeSettings(Guild guild, int strikes, int deleteThresh, int strikeThresh) { invalidateCache(guild); @@ -356,7 +378,7 @@ public final int maxMentions, maxRoleMentions; public final int maxLines; public final int raidmodeNumber, raidmodeTime; - public final int inviteStrikes, refStrikes, copypastaStrikes; + public final int inviteStrikes, refStrikes, copypastaStrikes, everyoneStrikes; public final int dupeStrikes, dupeDeleteThresh, dupeStrikeThresh; public final char dehoistChar; @@ -371,6 +393,7 @@ this.inviteStrikes = 0; this.refStrikes = 0; this.copypastaStrikes = 0; + this.everyoneStrikes = 0; this.dupeStrikes = 0; this.dupeDeleteThresh = 0; this.dupeStrikeThresh = 0; @@ -388,6 +411,7 @@ this.inviteStrikes = INVITE_STRIKES.getValue(rs); this.refStrikes = REF_STRIKES.getValue(rs); this.copypastaStrikes = COPYPASTA_STRIKES.getValue(rs); + this.everyoneStrikes = EVERYONE_STRIKES.getValue(rs); this.dupeStrikes = DUPE_STRIKES.getValue(rs); this.dupeDeleteThresh = DUPE_DELETE_THRESH.getValue(rs); this.dupeStrikeThresh = DUPE_STRIKE_THRESH.getValue(rs);