From db943f7e0582ecc8b15e66c2ec3d238f0ed44e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenzo=20Dellac=C3=A0?= Date: Mon, 19 Dec 2022 00:05:36 +0100 Subject: [PATCH] Fix messages with newlines not being handled for commands --- .../hidekobot/listeners/MessageCommandListener.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/wtf/beatrice/hidekobot/listeners/MessageCommandListener.java b/src/main/java/wtf/beatrice/hidekobot/listeners/MessageCommandListener.java index 194749c..84fe056 100644 --- a/src/main/java/wtf/beatrice/hidekobot/listeners/MessageCommandListener.java +++ b/src/main/java/wtf/beatrice/hidekobot/listeners/MessageCommandListener.java @@ -57,10 +57,11 @@ public class MessageCommandListener extends ListenerAdapter @Override public void onMessageReceived(@NotNull MessageReceivedEvent event) { - String eventMessage = event.getMessage().getContentDisplay(); + // warning: we are getting the RAW value of the message content, not the DISPLAY value! + String eventMessage = event.getMessage().getContentRaw(); // check if the sent message matches the bot activation regex (prefix, name, ...) - if(!eventMessage.toLowerCase().matches(commandRegex + ".*")) + if(!eventMessage.toLowerCase().matches(commandRegex + "((.|\\n)*)")) return; // generate args from the string @@ -120,6 +121,7 @@ public class MessageCommandListener extends ListenerAdapter String[] commandArgs; if(commandObject.passRawArgs()) { + // remove first argument, which is the command label argsString = argsString.replaceAll("^[\\S]+\\s+", ""); // pass all other arguments as a single argument as the first array element