diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 758d20b71..bd7a40dc2 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):