From 258fae47589a2fb8338fbca6c21e2e53b61bdbc3 Mon Sep 17 00:00:00 2001 From: Tommy Chow Date: Wed, 12 Jan 2022 11:13:57 -0500 Subject: [PATCH] Fix irc message index error --- lib/models/irc_message.dart | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/models/irc_message.dart b/lib/models/irc_message.dart index 2e808f22..4e1fb061 100644 --- a/lib/models/irc_message.dart +++ b/lib/models/irc_message.dart @@ -512,20 +512,7 @@ class IRCMessage { // Also remove any "INVALID/UNDEFINED" Unicode characters. // Rendering this character on iOS shows a question mark inside a square. // This character is used by some clients to bypass restrictions on repeating message. - var message = splitMessage.length > 3 - ? splitMessage.sublist(3).map((word) => word.replaceAll('\u{E0000}', '').trim()).where((element) => element != '').join(' ').substring(1) - : null; - - // Check if IRC actions like "/me" were called. - var action = false; - if (message != null && message.startsWith('\x01') && message.endsWith('\x01')) { - action = true; - message = message.substring(8, message.length - 1); - } - - // Check if the message mentions the logged-in user - var mention = false; - if (message != null && userLogin != null) mention = message.toLowerCase().contains(userLogin); + var message = splitMessage.length > 3 ? splitMessage.sublist(3).join(' ').substring(1) : null; // Now process any Twitch emotes contained in the message tags. // The map containing emotes from the user's tags to their URL. @@ -568,6 +555,22 @@ class IRCMessage { } } + var action = false; + var mention = false; + if (message != null) { + // Check if IRC actions like "/me" were called. + if (message.startsWith('\x01') && message.endsWith('\x01')) { + action = true; + message = message.substring(8, message.length - 1); + } + + // Check if the message mentions the logged-in user + if (userLogin != null) mention = message.toLowerCase().contains(userLogin); + + // Escape the message + message = message.split(' ').map((word) => word.replaceAll('\u{E0000}', '').trim()).where((element) => element != '').join(' '); + } + // Check and parse the command. // The majority of messages will be PRIVMSG, so check that first. final Command messageCommand;