diff --git a/lists/copypastas.txt b/lists/copypastas.txt index b6c9de4..863731d 100644 --- a/lists/copypastas.txt +++ b/lists/copypastas.txt @@ -1 +1,6 @@ -cooldog will never be cool | \ No newline at end of file +Cooldog || ╰━▅╮ && ╰╮ ┳━━╯ && ╰┳╯ +Dog || ╰┳┳┳╯ && ▔╰━╯ && ╱╲╱╲▏ +Fake PSA || out for a Discord && going around && those who accept && send this to as many && if you see this +Memecat || Λ_Λ && ( 'ㅅ' ) && > ⌒ヽ +Bob || /▌ && /\ && This is bob +Navy Seals || say about me && I’ll have you know I && I am trained && Think again && Not only am I extensively trained && kiddo diff --git a/src/main/java/com/jagrosh/vortex/Vortex.java b/src/main/java/com/jagrosh/vortex/Vortex.java index 6b2184c..ab6fa72 100644 --- a/src/main/java/com/jagrosh/vortex/Vortex.java +++ b/src/main/java/com/jagrosh/vortex/Vortex.java @@ -42,6 +42,7 @@ import com.jagrosh.vortex.logging.ModLogger; import com.jagrosh.vortex.logging.TextUploader; import com.jagrosh.vortex.utils.FormatUtil; +import java.util.concurrent.TimeUnit; import net.dv8tion.jda.bot.sharding.DefaultShardManagerBuilder; import net.dv8tion.jda.bot.sharding.ShardManager; import net.dv8tion.jda.core.entities.ChannelType; @@ -139,7 +140,7 @@ // Automoderation new AntiinviteCmd(this), - //new AnticopypastaCmd(this), + new AnticopypastaCmd(this), new AntirefCmd(this), new MaxlinesCmd(this), new MaxmentionsCmd(this), @@ -156,7 +157,8 @@ // Owner new EvalCmd(this), - new DebugCmd(this) + new DebugCmd(this), + new ReloadCmd(this) ) .setHelpConsumer(event -> event.replyInDm(FormatUtil.formatHelp(event, this), m -> { @@ -181,6 +183,8 @@ .build(); modlog.start(); + + threadpool.scheduleWithFixedDelay(() -> cleanPremium(), 0, 2, TimeUnit.HOURS); } public EventWaiter getEventWaiter() diff --git a/src/main/java/com/jagrosh/vortex/automod/AutoMod.java b/src/main/java/com/jagrosh/vortex/automod/AutoMod.java index 322a165..90aafa7 100644 --- a/src/main/java/com/jagrosh/vortex/automod/AutoMod.java +++ b/src/main/java/com/jagrosh/vortex/automod/AutoMod.java @@ -20,7 +20,6 @@ import com.jagrosh.vortex.database.managers.AutomodManager.AutomodSettings; import com.jagrosh.vortex.utils.FixedCache; import com.jagrosh.vortex.utils.OtherUtil; -import com.jagrosh.vortex.utils.URLResolver; import java.time.OffsetDateTime; import java.time.temporal.ChronoUnit; import java.util.ArrayList; @@ -33,7 +32,6 @@ import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.Guild.VerificationLevel; -import net.dv8tion.jda.core.entities.Invite; import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.core.entities.TextChannel; @@ -67,12 +65,24 @@ private final URLResolver urlResolver = new URLResolver(); private final InviteResolver inviteResolver = new InviteResolver(); + private final CopypastaResolver copypastaResolver = new CopypastaResolver(); private final FixedCache spams = new FixedCache<>(3000); private final HashMap latestGuildJoin = new HashMap<>(); public AutoMod(Vortex vortex) { this.vortex = vortex; + loadCopypastas(); + } + + public final void loadCopypastas() + { + this.copypastaResolver.load(); + } + + public final void loadSafeDomains() + { + this.urlResolver.loadSafeDomains(); } public void enableRaidMode(Guild guild, Member moderator, OffsetDateTime now, String reason) @@ -204,6 +214,18 @@ return true; } + public void dehoist(Member member) + { + if(!shouldPerformAutomod(member, null)) + return; + + AutomodSettings settings = vortex.getDatabase().automod.getSettings(member.getGuild()); + if(settings==null) + return; + + + } + public void performAutomod(Message message) { //simple automod @@ -302,6 +324,17 @@ } } + // prevent copypastas + if(settings.copypastaStrikes > 0 && preventSpam) + { + String copypastaName = copypastaResolver.getCopypasta(message.getContentRaw()); + if(copypastaName!=null) + { + strikeTotal += settings.copypastaStrikes; + reason.append(", ").append(copypastaName).append(" copypasta"); + } + } + // anti-invite if(settings.inviteStrikes > 0 && preventInvites) { diff --git a/src/main/java/com/jagrosh/vortex/automod/CopypastaResolver.java b/src/main/java/com/jagrosh/vortex/automod/CopypastaResolver.java new file mode 100644 index 0000000..b8d2ac5 --- /dev/null +++ b/src/main/java/com/jagrosh/vortex/automod/CopypastaResolver.java @@ -0,0 +1,72 @@ +/* + * 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.automod; + +import com.jagrosh.vortex.utils.OtherUtil; +import java.util.HashMap; + +/** + * + * @author John Grosh (john.a.grosh@gmail.com) + */ +public class CopypastaResolver +{ + private final HashMap copypastas = new HashMap<>(); + + public void load() + { + String[] lines = OtherUtil.readLines("copypastas"); + if(lines.length!=0) + { + copypastas.clear(); + String name; + String[] words; + for(String line: lines) + { + name = line.substring(0, line.indexOf("||")).trim(); + words = line.substring(line.indexOf("||")+2).trim().split("\\s+&&\\s+"); + for(int i=0; i110 && counts[1]>110) + return; List punishments = vortex.getDatabase().actions.getPunishments(moderator.getGuild(), counts[0], counts[1]); String dmmsg = String.format(STRIKE_FORMAT, number, moderator.getGuild().getName(), reason); if(punishments.isEmpty()) diff --git a/src/main/java/com/jagrosh/vortex/commands/owner/EvalCmd.java b/src/main/java/com/jagrosh/vortex/commands/owner/EvalCmd.java index aeee4d4..6222f7a 100644 --- a/src/main/java/com/jagrosh/vortex/commands/owner/EvalCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/owner/EvalCmd.java @@ -47,11 +47,12 @@ se.put("jda", event.getJDA()); se.put("guild", event.getGuild()); se.put("channel", event.getChannel()); + String args = event.getArgs().replaceAll("([^(]+?)\\s*->", "function($1)"); event.async(() -> { try { - event.replySuccess("Evaluated Successfully:\n```\n"+se.eval(event.getArgs())+" ```"); + event.replySuccess("Evaluated Successfully:\n```\n"+se.eval(args)+" ```"); } catch(Exception e) { diff --git a/src/main/java/com/jagrosh/vortex/commands/owner/ReloadCmd.java b/src/main/java/com/jagrosh/vortex/commands/owner/ReloadCmd.java new file mode 100644 index 0000000..d0c920a --- /dev/null +++ b/src/main/java/com/jagrosh/vortex/commands/owner/ReloadCmd.java @@ -0,0 +1,63 @@ +/* + * 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.owner; + +import com.jagrosh.jdautilities.command.Command; +import com.jagrosh.jdautilities.command.CommandEvent; +import com.jagrosh.vortex.Vortex; +import com.jagrosh.vortex.commands.CommandExceptionListener; +import com.jagrosh.vortex.commands.CommandExceptionListener.CommandErrorException; + +/** + * + * @author John Grosh (john.a.grosh@gmail.com) + */ +public class ReloadCmd extends Command +{ + private final Vortex vortex; + + public ReloadCmd(Vortex vortex) + { + this.vortex = vortex; + this.name = "reload"; + this.arguments = ""; + this.help = "reloads a file"; + this.ownerCommand = true; + this.guildOnly = false; + this.hidden = true; + } + + @Override + protected void execute(CommandEvent event) + { + switch(event.getArgs().toLowerCase()) + { + case "ref": + event.replyWarning("Not yet implemented"); + break; + case "safe": + vortex.getAutoMod().loadSafeDomains(); + event.replySuccess("Reloaded safe domains"); + break; + case "copy": + vortex.getAutoMod().loadCopypastas(); + event.replySuccess("Reloaded copypastas"); + break; + default: + throw new CommandErrorException("Invalid reload selection"); + } + } +} diff --git a/src/main/java/com/jagrosh/vortex/commands/tools/DehoistCmd.java b/src/main/java/com/jagrosh/vortex/commands/tools/DehoistCmd.java index 82b9ef3..a2ab32d 100644 --- a/src/main/java/com/jagrosh/vortex/commands/tools/DehoistCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/tools/DehoistCmd.java @@ -56,7 +56,7 @@ { char symbol; if(event.getArgs().isEmpty()) - symbol = valid[valid.length-1]; + symbol = valid[0]; else if(event.getArgs().length()==1) symbol = event.getArgs().charAt(0); else