chat notifier: fix matching < and > in chat messages

This commit is contained in:
Adam
2019-06-15 19:28:10 -06:00
parent dfef693211
commit 8988226d1c
2 changed files with 43 additions and 2 deletions

View File

@@ -117,9 +117,12 @@ public class ChatNotificationsPlugin extends Plugin
{
List<String> items = Text.fromCSV(config.highlightWordsString());
String joined = items.stream()
.map(Text::escapeJagex) // we compare these strings to the raw Jagex ones
.map(Pattern::quote)
.collect(Collectors.joining("|"));
highlightMatcher = Pattern.compile("\\b(" + joined + ")\\b", Pattern.CASE_INSENSITIVE);
// To match <word> \b doesn't work due to <> not being in \w,
// so match \b or \s
highlightMatcher = Pattern.compile("(?:\\b|(?<=\\s))(" + joined + ")(?:\\b|(?=\\s))", Pattern.CASE_INSENSITIVE);
}
}
@@ -127,7 +130,6 @@ public class ChatNotificationsPlugin extends Plugin
public void onChatMessage(ChatMessage chatMessage)
{
MessageNode messageNode = chatMessage.getMessageNode();
String nodeValue = Text.removeTags(messageNode.getValue());
boolean update = false;
switch (chatMessage.getType())
@@ -177,6 +179,7 @@ public class ChatNotificationsPlugin extends Plugin
if (highlightMatcher != null)
{
String nodeValue = messageNode.getValue();
Matcher matcher = highlightMatcher.matcher(nodeValue);
boolean found = false;
StringBuffer stringBuffer = new StringBuffer();