From 15a7cb6e43939a110fcac83a83f83f9d0aac0d85 Mon Sep 17 00:00:00 2001 From: Bella Date: Sun, 19 Apr 2020 08:55:04 -0400 Subject: [PATCH 1/3] remove some unnecessary modes from antispam --- .../kami/module/modules/chat/AntiSpam.java | 44 ++----------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/chat/AntiSpam.java b/src/main/java/me/zeroeightsix/kami/module/modules/chat/AntiSpam.java index 2afb6439..4d9689aa 100644 --- a/src/main/java/me/zeroeightsix/kami/module/modules/chat/AntiSpam.java +++ b/src/main/java/me/zeroeightsix/kami/module/modules/chat/AntiSpam.java @@ -27,7 +27,7 @@ import static me.zeroeightsix.kami.util.MessageSendHelper.sendRawChatMessage; * Created 19 November 2019 by hub * Updated 12 January 2020 by hub * Updated 19 February 2020 by aUniqueUser - * Updated by dominikaaaa on 18/04/20 + * Updated by dominikaaaa on 19/04/20 */ @Module.Info( name = "AntiSpam", @@ -45,7 +45,6 @@ public class AntiSpam extends Module { private Setting insulters = register(Settings.booleanBuilder("Insulters").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build()); private Setting greeters = register(Settings.booleanBuilder("Greeters").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build()); private Setting ips = register(Settings.booleanBuilder("Server Ips").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build()); - private Setting wordsLongerThen = register(Settings.booleanBuilder("11+ long words").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build()); private Setting specialCharEnding = register(Settings.booleanBuilder("Special Ending").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build()); private Setting specialCharBegin = register(Settings.booleanBuilder("Special Begin").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build()); private Setting iJustThanksTo = register(Settings.booleanBuilder("I just...thanks to").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build()); @@ -57,9 +56,6 @@ public class AntiSpam extends Module { private Setting greenText = register(Settings.booleanBuilder("Green Text").withValue(false).withVisibility(v -> p.getValue().equals(Page.TWO)).build()); private Setting numberSuffix = register(Settings.booleanBuilder("Number Ending").withValue(true).withVisibility(v -> p.getValue().equals(Page.TWO)).build()); private Setting numberPrefix = register(Settings.booleanBuilder("Number Begin").withValue(false).withVisibility(v -> p.getValue().equals(Page.TWO)).build()); - private Setting tradeChat = register(Settings.booleanBuilder("Trade Chat").withValue(true).withVisibility(v -> p.getValue().equals(Page.TWO)).build()); - private Setting hypixelShills = register(Settings.booleanBuilder("Hypixel Shills").withValue(true).withVisibility(v -> p.getValue().equals(Page.TWO)).build()); - private Setting ipsAgr = register(Settings.booleanBuilder("Ips Aggressive").withValue(false).withVisibility(v -> p.getValue().equals(Page.TWO)).build()); private Setting duplicates = register(Settings.booleanBuilder("Duplicates").withValue(true).withVisibility(v -> p.getValue().equals(Page.TWO)).build()); private Setting duplicatesTimeout = register(Settings.integerBuilder("Duplicates Timeout").withMinimum(1).withValue(30).withMaximum(600).withVisibility(v -> duplicates.getValue() && p.getValue().equals(Page.TWO)).build()); private Setting webLinks = register(Settings.booleanBuilder("Web Links").withValue(false).withVisibility(v -> p.getValue().equals(Page.TWO)).build()); @@ -129,7 +125,7 @@ public class AntiSpam extends Module { private boolean detectSpam(String message) { for (Map.Entry, String[]> entry : settingMap.entrySet()) { - if (entry.getKey().getValue() && findPatterns(entry.getValue(), message, true)) { + if (entry.getKey().getValue() && findPatterns(entry.getValue(), message)) { sendResult(entry.getKey().getName(), message); return true; } @@ -158,10 +154,8 @@ public class AntiSpam extends Module { return Pattern.compile(ownFilter, Pattern.CASE_INSENSITIVE).matcher(message).find(); } - private boolean findPatterns(String[] patterns, String string, boolean removeUsername) { - if (removeUsername) { - string = string.replaceAll("<[^>]*> ", ""); // remove username first - } + private boolean findPatterns(String[] patterns, String string) { + string = string.replaceAll("<[^>]*> ", ""); // remove username first for (String pattern : patterns) { if (Pattern.compile(pattern, Pattern.CASE_INSENSITIVE).matcher(string).find()) { return true; @@ -171,7 +165,6 @@ public class AntiSpam extends Module { } private Map, String[]> settingMap = new HashMap, String[]>() {{ - put(wordsLongerThen, FilterPatterns.LONG_WORD); put(greenText, FilterPatterns.GREEN_TEXT); put(specialCharBegin, FilterPatterns.SPECIAL_BEGINNING); put(specialCharEnding, FilterPatterns.SPECIAL_ENDING); @@ -183,13 +176,10 @@ public class AntiSpam extends Module { put(discordLinks, FilterPatterns.DISCORD); put(webLinks, FilterPatterns.WEB_LINK); put(ips, FilterPatterns.IP_ADDR); - put(ipsAgr, FilterPatterns.IP_ADDR_AGR); put(announcers, FilterPatterns.ANNOUNCER); put(spammers, FilterPatterns.SPAMMER); put(insulters, FilterPatterns.INSULTER); put(greeters, FilterPatterns.GREETER); - put(hypixelShills, FilterPatterns.HYPIXEL_SHILLS); - put(tradeChat, FilterPatterns.TRADE_CHAT); }}; private static class FilterPatterns { @@ -316,13 +306,6 @@ public class AntiSpam extends Module { ".+ left the game", }; - private static final String[] HYPIXEL_SHILLS = { - "/p join", - "/party join", - "road to", - "private games" - }; - private static final String[] DISCORD = { "discord.gg", "discordapp.com", @@ -342,11 +325,6 @@ public class AntiSpam extends Module { "^>.+$", }; - private static final String[] TRADE_CHAT = { - "buy", - "sell", - }; - private static final String[] WEB_LINK = { "http:\\/\\/", "https:\\/\\/", @@ -360,15 +338,6 @@ public class AntiSpam extends Module { ".*\\..*\\:\\d{1,5}$", }; - private static final String[] IP_ADDR_AGR = { - ".*\\..*$", - }; - - private static final String[] LONG_WORD = { -// "\\b\\w{" + getCharacters() + ",256}\\b", - "\\b\\w{11,256}\\b", - }; - private static final String[] OWNS_ME_AND_ALL = { "owns me and all", }; @@ -387,11 +356,6 @@ public class AntiSpam extends Module { }; } -// private static Integer getCharacters() { -// AntiSpam antiSpam = ((AntiSpam) ModuleManager.getModuleByName("AntiSpam")); -// return antiSpam.characters.getValue(); -// } - private void sendResult(String name, String message) { if (showBlocked.getValue().equals(ShowBlocked.CHAT)) sendChatMessage(getChatName() + name + ": " + message); else if (showBlocked.getValue().equals(ShowBlocked.LOG_FILE)) From 9e06a4ba6cfd2f1b5b06c51e83a8a5099dbc7cf6 Mon Sep 17 00:00:00 2001 From: Bella Date: Sun, 19 Apr 2020 09:03:39 -0400 Subject: [PATCH 2/3] antispam fix special ending and change it to off by default --- .../me/zeroeightsix/kami/module/modules/chat/AntiSpam.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/chat/AntiSpam.java b/src/main/java/me/zeroeightsix/kami/module/modules/chat/AntiSpam.java index 4d9689aa..cdbb5ff0 100644 --- a/src/main/java/me/zeroeightsix/kami/module/modules/chat/AntiSpam.java +++ b/src/main/java/me/zeroeightsix/kami/module/modules/chat/AntiSpam.java @@ -54,7 +54,7 @@ public class AntiSpam extends Module { /* Page Two */ private Setting ownsMeAndAll = register(Settings.booleanBuilder("Owns Me And All").withValue(true).withVisibility(v -> p.getValue().equals(Page.TWO)).build()); private Setting greenText = register(Settings.booleanBuilder("Green Text").withValue(false).withVisibility(v -> p.getValue().equals(Page.TWO)).build()); - private Setting numberSuffix = register(Settings.booleanBuilder("Number Ending").withValue(true).withVisibility(v -> p.getValue().equals(Page.TWO)).build()); + private Setting numberSuffix = register(Settings.booleanBuilder("Number Ending").withValue(false).withVisibility(v -> p.getValue().equals(Page.TWO)).build()); private Setting numberPrefix = register(Settings.booleanBuilder("Number Begin").withValue(false).withVisibility(v -> p.getValue().equals(Page.TWO)).build()); private Setting duplicates = register(Settings.booleanBuilder("Duplicates").withValue(true).withVisibility(v -> p.getValue().equals(Page.TWO)).build()); private Setting duplicatesTimeout = register(Settings.integerBuilder("Duplicates Timeout").withMinimum(1).withValue(30).withMaximum(600).withVisibility(v -> duplicates.getValue() && p.getValue().equals(Page.TWO)).build()); @@ -352,7 +352,7 @@ public class AntiSpam extends Module { }; private static final String[] SPECIAL_ENDING = { - "[/@#^()\\[\\]{}<>|\\-+=\\\\]", + "[/@#^()\\[\\]{}<>|\\-+=\\\\]$", }; } From e3b20340277009587159b26038f3b8350c934ae9 Mon Sep 17 00:00:00 2001 From: Dewy REDACTED Date: Sun, 19 Apr 2020 15:55:29 +0100 Subject: [PATCH 3/3] added LoginMessage module --- .../module/modules/chat/LoginMessage.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/main/java/me/zeroeightsix/kami/module/modules/chat/LoginMessage.java diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/chat/LoginMessage.java b/src/main/java/me/zeroeightsix/kami/module/modules/chat/LoginMessage.java new file mode 100644 index 00000000..0c623409 --- /dev/null +++ b/src/main/java/me/zeroeightsix/kami/module/modules/chat/LoginMessage.java @@ -0,0 +1,52 @@ +package me.zeroeightsix.kami.module.modules.chat; + +import me.zero.alpine.listener.EventHandler; +import me.zero.alpine.listener.Listener; +import me.zeroeightsix.kami.KamiMod; +import me.zeroeightsix.kami.event.events.PacketEvent; +import me.zeroeightsix.kami.module.Module; +import me.zeroeightsix.kami.util.MessageSendHelper; +import net.minecraft.network.play.server.SPacketChat; + +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; + +@Module.Info( + name = "LoginMessage", + description = "Sends a given message to public chat on login.", + category = Module.Category.CHAT +) +public class LoginMessage extends Module { + private String loginMessage; + private boolean sent = false; + + @Override + protected void onEnable() { + BufferedReader reader; + + try { + MessageSendHelper.sendChatMessage(getChatName() + "Finding login message from loginmsg.txt..."); + reader = new BufferedReader(new FileReader("loginmsg.txt")); + + loginMessage = reader.readLine(); + + reader.close(); + } catch (FileNotFoundException e) { + MessageSendHelper.sendErrorMessage(getChatName() + "The file '&7loginmsg.txt&f' was not found in your .minecraft folder. Create it and add a message to enable this module."); + disable(); + } catch (IOException e) { + KamiMod.log.error(e); + } + } + + @EventHandler + public Listener serverConnectedEventListener = new Listener<>(event -> { + if (event.getPacket() instanceof SPacketChat && !sent) { + mc.player.sendChatMessage(loginMessage); + + sent = true; + } + }); +}