From c0a1681b27a0f7c126fdec8b0a10c75582649ced Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Thu, 19 Oct 2023 16:00:35 +0700 Subject: [PATCH] temporarily fix this can be bypassed with something like random strings i am not sure how to make it auto reconnect yet but should be simple --- .../chomens_bot/plugins/IRCPlugin.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/IRCPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/IRCPlugin.java index bf6472f..a5e6374 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/IRCPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/IRCPlugin.java @@ -23,6 +23,8 @@ public class IRCPlugin extends IRCMessageLoop { private final Map> messageQueue = new HashMap<>(); + private String lastMessage = ""; + public IRCPlugin (Configuration config) { super(config.irc.host, config.irc.port); @@ -133,13 +135,19 @@ public class IRCPlugin extends IRCMessageLoop { final String stringifiedName = ComponentUtilities.stringify(message.displayName); final String stringifiedContents = ComponentUtilities.stringify(message.contents); + final String toSend = String.format( + "<%s> %s", + stringifiedName, + stringifiedContents + ); + + if (lastMessage.equals(toSend)) return; + + lastMessage = toSend; + addMessageToQueue( bot, - String.format( - "<%s> %s", - stringifiedName, - stringifiedContents - ) + toSend ); }