diff --git a/lists/copypastas.txt b/lists/copypastas.txt index d70d30d..9d7be12 100644 --- a/lists/copypastas.txt +++ b/lists/copypastas.txt @@ -1,30 +1,29 @@ -// Copypastas -// Bits of text that tend to be copied and pasted - -// False Discord PSA -False PSA || out for a Discord && going around && those who accept && send this to as many && if you see this -Fake Hacker PSA || not accept friend request from && hackers && tell everyone && copy && paste -Fake Discord shutdown || discord && clos && populated && active && please send && copy && paste && deleted without hesitation - -// Share or else -Cooldog || ╰━▅╮ && ╰╮ && ┳━━╯ && ╰┳╯ -Dog || ╰┳┳┳╯ && ▔╰━╯ && ╱╲╱╲▏ -Memecat || Λ_Λ && ( 'ㅅ' ) && > ⌒ヽ -"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 - -// Unicode -Bob || /▌ && /\ && This is bob -Lennipede || ╚═(███)═╝ && Lenn -Doge || ▐▄█▀▒▒▒▒▄▀█▄ && ▐▄█▄█▌▄▒▀▒ && ▒▀▀▄▄▒▒▒▄▒ - -// Text -Navy Seals || say about me && ll have you know I && I am trained && Think again && Not only am I extensively trained && kid -Rick & Morty || have to have a very high IQ && extremely && solid grasp && deftly woven && heavily && intellectual capacity && cryptic reference -Shrek || years old && is love && is life && spread && push against && straight in the - - -// Scams -Fake Libra Site || getlⅰbra.tech -Fake Libra Site (2) || buylⅰbra.τech +// Copypastas +// Bits of text that tend to be copied and pasted + +// False Discord PSA +False PSA || out for a Discord && going around && those who accept && send this to as many && if you see this +Fake Hacker PSA || not accept && friend request from && hacker && tell everyone && copy && paste +Fake Discord shutdown || discord && clos && populated && active && please send && copy && paste && deleted without hesitation + +// Share or else +Cooldog || ╰━▅╮ && ╰╮ && ┳━━╯ && ╰┳╯ +Dog || ╰┳┳┳╯ && ▔╰━╯ && ╱╲╱╲▏ +Memecat || Λ_Λ && ( 'ㅅ' ) && > ⌒ヽ +Memecat (2) || Λ_Λ && ˇωˇ && > ⌒ヽ +"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 + +// Unicode +Bob || /▌ && /\ && This is bob +Lennipede || ╚═(███)═╝ && Lenn +Doge || ▐▄█▀▒▒▒▒▄▀█▄ && ▐▄█▄█▌▄▒▀▒ && ▒▀▀▄▄▒▒▒▄▒ + +// Text +Navy Seals || say about me && ll have you know I && I am trained && Think again && Not only am I extensively trained && kid +Rick & Morty || have to have a very high IQ && extremely && solid grasp && deftly woven && heavily && intellectual capacity && cryptic reference +Shrek || years old && is love && is life && spread && push against && straight in the + +// Scams +Fake Libra Site || lⅰbra diff --git a/src/main/java/com/jagrosh/vortex/Vortex.java b/src/main/java/com/jagrosh/vortex/Vortex.java index 505b50e..dff4d18 100644 --- a/src/main/java/com/jagrosh/vortex/Vortex.java +++ b/src/main/java/com/jagrosh/vortex/Vortex.java @@ -162,6 +162,7 @@ new AnnounceCmd(), new AuditCmd(), new DehoistCmd(), + new ExportCmd(this), new InvitepruneCmd(this), new LookupCmd(this), diff --git a/src/main/java/com/jagrosh/vortex/automod/AutoMod.java b/src/main/java/com/jagrosh/vortex/automod/AutoMod.java index 3cd33c2..114c622 100644 --- a/src/main/java/com/jagrosh/vortex/automod/AutoMod.java +++ b/src/main/java/com/jagrosh/vortex/automod/AutoMod.java @@ -52,7 +52,7 @@ */ public class AutoMod { - private static final Pattern INVITES = Pattern.compile("discord\\s?(?:(?:\\.|dot|\\(\\.\\)|\\(dot\\))\\s?gg|app\\s?\\.\\s?com\\s?\\/\\s?invite)\\s?\\/\\s?([A-Z0-9-]{2,18})", + private static final Pattern INVITES = Pattern.compile("discord\\s?(?:(?:\\.|dot|\\(\\.\\)|\\(dot\\))\\s?gg|(?:app)?\\s?\\.\\s?com\\s?\\/\\s?invite)\\s?\\/\\s?([A-Z0-9-]{2,18})", Pattern.CASE_INSENSITIVE); private static final Pattern REF = Pattern.compile("https?:\\/\\/\\S+(?:\\/ref\\/|[?&#]ref(?:errer|erral)?=)\\S+", Pattern.CASE_INSENSITIVE); diff --git a/src/main/java/com/jagrosh/vortex/commands/owner/ExportCmd.java b/src/main/java/com/jagrosh/vortex/commands/owner/ExportCmd.java deleted file mode 100644 index e6bd74a..0000000 --- a/src/main/java/com/jagrosh/vortex/commands/owner/ExportCmd.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2020 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 net.dv8tion.jda.core.Permission; -import org.json.JSONObject; - -/** - * - * @author John Grosh (john.a.grosh@gmail.com) - */ -public class ExportCmd extends Command -{ - private final Vortex vortex; - - public ExportCmd(Vortex vortex) - { - this.vortex = vortex; - this.name = "export"; - this.arguments = ""; - this.help = "exports all server data as json"; - this.category = new Category("Tools"); - this.userPermissions = new Permission[]{Permission.MESSAGE_ATTACH_FILES}; - this.ownerCommand = true; - } - - @Override - protected void execute(CommandEvent event) - { - long gid; - try - { - gid = Long.parseLong(event.getArgs()); - } - catch(NumberFormatException ex) - { - event.reactError(); - return; - } - JSONObject obj = new JSONObject(); - - } -} diff --git a/src/main/java/com/jagrosh/vortex/commands/tools/ExportCmd.java b/src/main/java/com/jagrosh/vortex/commands/tools/ExportCmd.java new file mode 100644 index 0000000..dc36123 --- /dev/null +++ b/src/main/java/com/jagrosh/vortex/commands/tools/ExportCmd.java @@ -0,0 +1,64 @@ +/* + * Copyright 2020 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.tools; + +import com.jagrosh.jdautilities.command.Command; +import com.jagrosh.jdautilities.command.CommandEvent; +import com.jagrosh.vortex.Vortex; +import com.jagrosh.vortex.database.Database; +import net.dv8tion.jda.core.Permission; +import net.dv8tion.jda.core.entities.Guild; +import org.json.JSONObject; + +/** + * + * @author John Grosh (john.a.grosh@gmail.com) + */ +public class ExportCmd extends Command +{ + private final Vortex vortex; + + public ExportCmd(Vortex vortex) + { + this.vortex = vortex; + this.name = "export"; + this.help = "exports all server data as json"; + this.category = new Category("Tools"); + this.botPermissions = new Permission[]{Permission.MESSAGE_ATTACH_FILES}; + this.userPermissions = new Permission[]{Permission.ADMINISTRATOR}; + this.cooldown = 60*30; + this.cooldownScope = CooldownScope.GUILD; + this.guildOnly = true; + } + + @Override + protected void execute(CommandEvent event) + { + Guild g = event.getGuild(); + Database db = vortex.getDatabase(); + JSONObject obj = new JSONObject() + .put("automod", db.automod.getSettingsJson(g)) + .put("settings", db.settings.getSettingsJson(g)) + .put("ignores", db.ignores.getIgnoresJson(g)) + .put("strikes", db.strikes.getAllStrikesJson(g)) + .put("punishments", db.actions.getAllPunishmentsJson(g)) + .put("tempmutes", db.tempmutes.getAllMutesJson(g)) + .put("tempbans", db.tempbans.getAllBansJson(g)) + .put("inviteWhitelist", db.inviteWhitelist.getWhitelistJson(g)) + .put("filters", db.filters.getFiltersJson(g)); + event.getChannel().sendFile(obj.toString(1).getBytes(), "vortex_data_" + g.getId() + ".json").queue(); + } +} 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 923a4fa..9228151 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/AutomodManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/AutomodManager.java @@ -26,6 +26,7 @@ import java.sql.SQLException; import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.MessageEmbed.Field; +import org.json.JSONObject; /** * @@ -112,6 +113,26 @@ /*+ "\u200B"*/, true); } + public JSONObject getSettingsJson(Guild guild) + { + AutomodSettings settings = getSettings(guild); + return new JSONObject() + .put("copypastaStrikes", settings.copypastaStrikes) + .put("dehoistChar", ""+settings.dehoistChar) + .put("dupeDeleteThresh", settings.dupeDeleteThresh) + .put("dupeStrikeThresh", settings.dupeStrikeThresh) + .put("dupeStrikes", settings.dupeStrikes) + .put("everyoneStrikes", settings.everyoneStrikes) + .put("inviteStrikes", settings.inviteStrikes) + .put("maxLines", settings.maxLines) + .put("maxMentions", settings.maxMentions) + .put("maxRoleMentions", settings.maxRoleMentions) + .put("raidmodeNumber", settings.raidmodeNumber) + .put("raidmodeTime", settings.raidmodeTime) + .put("refStrikes", settings.refStrikes) + .put("resolveUrls", settings.resolveUrls); + } + public boolean hasSettings(Guild guild) { return read(selectAll(GUILD_ID.is(guild.getIdLong())), rs -> {return rs.next();}); diff --git a/src/main/java/com/jagrosh/vortex/database/managers/FilterManager.java b/src/main/java/com/jagrosh/vortex/database/managers/FilterManager.java index 1def79c..291abe0 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/FilterManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/FilterManager.java @@ -27,6 +27,8 @@ import java.util.List; import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.MessageEmbed.Field; +import org.json.JSONArray; +import org.json.JSONObject; /** * @@ -90,6 +92,14 @@ return new Field(SETTINGS_TITLE, sb.toString().trim(), true); } + public JSONObject getFiltersJson(Guild guild) + { + List filters = getFilters(guild); + JSONObject obj = new JSONObject(); + filters.forEach(f -> obj.put(f.name, new JSONObject().put("strikes",f.strikes).put("content", f.printContent()))); + return obj; + } + public boolean addFilter(Guild guild, Filter filter) { String shortname = shortnameOf(filter.name); diff --git a/src/main/java/com/jagrosh/vortex/database/managers/GuildSettingsDataManager.java b/src/main/java/com/jagrosh/vortex/database/managers/GuildSettingsDataManager.java index 5f7f311..b6a46eb 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/GuildSettingsDataManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/GuildSettingsDataManager.java @@ -35,6 +35,7 @@ import net.dv8tion.jda.core.entities.MessageEmbed.Field; import net.dv8tion.jda.core.entities.Role; import net.dv8tion.jda.core.entities.TextChannel; +import org.json.JSONObject; /** * @@ -104,6 +105,22 @@ + "\nTimezone: **"+settings.timezone+"**\n\u200B", true); } + public JSONObject getSettingsJson(Guild guild) + { + GuildSettings settings = getSettings(guild); + return new JSONObject() + .put("avatarlog", settings.avatarlog) + .put("messagelog", settings.messagelog) + .put("modRole", settings.modRole) + .put("modlog", settings.modlog) + .put("muteRole", settings.muteRole) + .put("prefix", settings.prefix) + .put("raidMode", settings.raidMode) + .put("serverlog", settings.serverlog) + .put("timezone", settings.timezone) + .put("voicelog", settings.voicelog); + } + public boolean hasSettings(Guild guild) { return read(selectAll(GUILD_ID.is(guild.getIdLong())), rs -> {return rs.next();}); diff --git a/src/main/java/com/jagrosh/vortex/database/managers/IgnoreManager.java b/src/main/java/com/jagrosh/vortex/database/managers/IgnoreManager.java index fe9eeb5..8f0c80c 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/IgnoreManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/IgnoreManager.java @@ -29,6 +29,7 @@ import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.core.entities.Role; import net.dv8tion.jda.core.entities.TextChannel; +import org.json.JSONArray; /** * @@ -47,6 +48,13 @@ super(connector, "IGNORED"); } + public JSONArray getIgnoresJson(Guild guild) + { + JSONArray array = new JSONArray(); + getIgnores(guild).forEach(id -> array.put(id)); + return array; + } + public boolean isIgnored(TextChannel tc) { return getIgnores(tc.getGuild()).contains(tc.getIdLong()); diff --git a/src/main/java/com/jagrosh/vortex/database/managers/InviteWhitelistManager.java b/src/main/java/com/jagrosh/vortex/database/managers/InviteWhitelistManager.java index 4f9f809..28b9286 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/InviteWhitelistManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/InviteWhitelistManager.java @@ -19,6 +19,7 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.IntStream; +import org.json.JSONArray; public class InviteWhitelistManager extends DataManager { @@ -131,6 +132,14 @@ cache.put(guild.getIdLong(), whitelist); return whitelist; } + + public JSONArray getWhitelistJson(Guild guild) + { + List list = readWhitelist(guild); + JSONArray arr = new JSONArray(); + list.forEach(id -> list.add(id)); + return arr; + } private void invalidateCache(Guild guild) { diff --git a/src/main/java/com/jagrosh/vortex/database/managers/PunishmentManager.java b/src/main/java/com/jagrosh/vortex/database/managers/PunishmentManager.java index 5548697..79946f5 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/PunishmentManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/PunishmentManager.java @@ -30,6 +30,7 @@ import java.util.stream.Collectors; import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.MessageEmbed.Field; +import org.json.JSONObject; /** * @@ -172,6 +173,14 @@ return new Field(STRIKES_TITLE, sb.toString().trim(), true); } + public JSONObject getAllPunishmentsJson(Guild guild) + { + JSONObject obj = new JSONObject(); + getAllPunishments(guild).forEach(p -> obj.put(Integer.toString(p.numStrikes), + new JSONObject().put("action", p.action.toString()).put("time", p.time))); + return obj; + } + public class Punishment { public final Action action; diff --git a/src/main/java/com/jagrosh/vortex/database/managers/StrikeManager.java b/src/main/java/com/jagrosh/vortex/database/managers/StrikeManager.java index 7a6e445..9dee2c3 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/StrikeManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/StrikeManager.java @@ -23,6 +23,8 @@ import java.util.Map; import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.Member; +import org.json.JSONArray; +import org.json.JSONObject; /** * @@ -108,4 +110,11 @@ return map; }); } + + public JSONObject getAllStrikesJson(Guild guild) + { + JSONObject obj = new JSONObject(); + getAllStrikes(guild).entrySet().forEach(e -> obj.put(Long.toString(e.getKey()), e.getValue())); + return obj; + } } diff --git a/src/main/java/com/jagrosh/vortex/database/managers/TempBanManager.java b/src/main/java/com/jagrosh/vortex/database/managers/TempBanManager.java index 026682b..6278a2d 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/TempBanManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/TempBanManager.java @@ -20,11 +20,15 @@ import com.jagrosh.easysql.SQLColumn; import com.jagrosh.easysql.columns.InstantColumn; import com.jagrosh.easysql.columns.LongColumn; +import com.jagrosh.vortex.utils.Pair; import java.time.Instant; import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; import net.dv8tion.jda.core.JDA; import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.entities.Guild; +import org.json.JSONObject; /** * @@ -47,6 +51,20 @@ return GUILD_ID+", "+USER_ID; } + public JSONObject getAllBansJson(Guild guild) + { + List> list = read(selectAll(GUILD_ID.is(guild.getId())), rs -> + { + List> arr = new ArrayList<>(); + while(rs.next()) + arr.add(new Pair<>(USER_ID.getValue(rs), FINISH.getValue(rs))); + return arr; + }); + JSONObject json = new JSONObject(); + list.forEach(p -> json.put(Long.toString(p.getKey()), p.getValue().toEpochMilli())); + return json; + } + public void setBan(Guild guild, long userId, Instant finish) { readWrite(selectAll(GUILD_ID.is(guild.getId())+" AND "+USER_ID.is(userId)), rs -> diff --git a/src/main/java/com/jagrosh/vortex/database/managers/TempMuteManager.java b/src/main/java/com/jagrosh/vortex/database/managers/TempMuteManager.java index 94d158f..797dcaa 100644 --- a/src/main/java/com/jagrosh/vortex/database/managers/TempMuteManager.java +++ b/src/main/java/com/jagrosh/vortex/database/managers/TempMuteManager.java @@ -20,13 +20,17 @@ import com.jagrosh.easysql.SQLColumn; import com.jagrosh.easysql.columns.InstantColumn; import com.jagrosh.easysql.columns.LongColumn; +import com.jagrosh.vortex.utils.Pair; import java.time.Instant; import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; import net.dv8tion.jda.core.JDA; import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.core.entities.Role; +import org.json.JSONObject; /** * @@ -49,6 +53,20 @@ return GUILD_ID+", "+USER_ID; } + public JSONObject getAllMutesJson(Guild guild) + { + List> list = read(selectAll(GUILD_ID.is(guild.getId())), rs -> + { + List> arr = new ArrayList<>(); + while(rs.next()) + arr.add(new Pair<>(USER_ID.getValue(rs), FINISH.getValue(rs))); + return arr; + }); + JSONObject json = new JSONObject(); + list.forEach(p -> json.put(Long.toString(p.getKey()), p.getValue().toEpochMilli())); + return json; + } + public boolean isMuted(Member member) { return read(selectAll(GUILD_ID.is(member.getGuild().getId())+" AND "+USER_ID.is(member.getUser().getId())+" AND "+FINISH.isGreaterThan(Instant.now().getEpochSecond())), diff --git a/src/main/java/com/jagrosh/vortex/logging/ModLogger.java b/src/main/java/com/jagrosh/vortex/logging/ModLogger.java index 9779794..1e04e43 100644 --- a/src/main/java/com/jagrosh/vortex/logging/ModLogger.java +++ b/src/main/java/com/jagrosh/vortex/logging/ModLogger.java @@ -77,7 +77,7 @@ } if(!toUpdate.isEmpty()) { - LOG.info("DEBUG Modlog updating " + toUpdate.size() + " guilds: " + toUpdate.toString()); + LOG.debug("DEBUG Modlog updating " + toUpdate.size() + " guilds: " + toUpdate.toString()); try { long time, diff; diff --git a/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java b/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java index 0b9401f..be96748 100644 --- a/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java +++ b/src/main/java/com/jagrosh/vortex/utils/FormatUtil.java @@ -48,8 +48,8 @@ return input.replace("\u202E","") // RTL override .replace("@everyone","@\u0435veryone") // cyrillic e .replace("@here","@h\u0435re") // cyrillic e - .replace("discord.gg/", "dis\u0441ord.gg/") // cyrillic c - .replace("@", "\u0DB8"); // failsafe + .replace("discord.gg/", "discord\u2024gg/") // one dot leader + .replace("@&", "\u0DB8&"); // role failsafe } public static String formatMessage(Message m) diff --git a/src/main/java/com/jagrosh/vortex/utils/Pair.java b/src/main/java/com/jagrosh/vortex/utils/Pair.java new file mode 100644 index 0000000..22c1776 --- /dev/null +++ b/src/main/java/com/jagrosh/vortex/utils/Pair.java @@ -0,0 +1,42 @@ +/* + * Copyright 2020 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.utils; + +/** + * + * @author John Grosh (john.a.grosh@gmail.com) + */ +public class Pair +{ + private final K key; + private final V value; + + public Pair(K key, V value) + { + this.key = key; + this.value = value; + } + + public K getKey() + { + return key; + } + + public V getValue() + { + return value; + } +}