From 4d4271435d43d2f663fb0286e73a362fe56d8416 Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 24 May 2019 21:28:43 +0100 Subject: [PATCH] Use regex to prevent highlights in github module --- modules/github/__init__.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/modules/github/__init__.py b/modules/github/__init__.py index 68228f62..a33ab951 100644 --- a/modules/github/__init__.py +++ b/modules/github/__init__.py @@ -477,16 +477,10 @@ class Module(ModuleManager.BaseModule): # will fire indefininitely. continue - s_lower = server.irc_lower(s) - while user.nickname_lower in s_lower: - index = s_lower.index(user.nickname_lower) - length = len(user.nickname_lower) + regex = re.compile(r".\b(%s)(%s)" % ( + user.nickname[0], user.nickname[1:]), re.I) + s = regex.sub("\\1\u200c\\2", s) - original = s[index:index+length] - original = utils.prevent_highlight(original) - - s = s[:index] + original + s[index+length:] - s_lower = server.irc_lower(s) return s def _short_url(self, url):