From d440bdddab3e500571706349f0dfbed9555daffe Mon Sep 17 00:00:00 2001
From: Jean-Marie Traissard <jim@lapin.org>
Date: Wed, 24 May 2006 16:15:49 +0000
Subject: [PATCH] Do not highlight in gc in case we are sure our nick is
 beginning of a real word (nick after = A->Z or a->z)

---
 src/groupchat_control.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/groupchat_control.py b/src/groupchat_control.py
index 758d20b718..bd7a40dc26 100644
--- a/src/groupchat_control.py
+++ b/src/groupchat_control.py
@@ -661,7 +661,22 @@ class GroupchatControl(ChatControlBase):
 		for word in text_splitted: # get each word of the text
 			for special_word in special_words:
 				if word.startswith(special_word):
-					return True
+					# get char after the word that highlight us
+					char_position = len(special_word)
+					refer_to_nick_char = \
+						word[char_position:char_position+1]
+					if (refer_to_nick_char != ''):
+						refer_to_nick_char_code = ord(refer_to_nick_char)
+						if ((refer_to_nick_char_code < 65 or refer_to_nick_char_code > 123)\
+							or (refer_to_nick_char_code < 97 and refer_to_nick_char_code > 90)):
+							return True
+						else: 
+							# This is A->Z or a->z, we can be sure our nick is the beginning
+							# of a real word, do not highlight. Note that we can probably 
+							# do a better detection of non-punctuation characters
+							return False
+					else: # Special word == word, no char after in word
+						return True 
 		return False
 
 	def set_subject(self, subject):
-- 
GitLab