From 2a080b37a665d435a3eecceca6ad7e8132a490d5 Mon Sep 17 00:00:00 2001 From: jomo Date: Sun, 27 Jul 2014 19:49:55 +0200 Subject: [PATCH] mentio readability, remove <> around mention highlight --- mentio.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mentio.py b/mentio.py index bb065f7..16db9ff 100644 --- a/mentio.py +++ b/mentio.py @@ -6,7 +6,7 @@ from traceback import format_exc as print_traceback mentions = open_json_file("mentio", {}) max_amount = 3 arrow = colorify(u"&r&7\u2192&r") -regex = reg_compile(u"\u00A7[\\da-fk-or]") +colors_reg = reg_compile(u"\u00A7[\\da-fk-or]") @hook.event("player.AsyncPlayerChatEvent", "high") @@ -31,8 +31,10 @@ def onChat(event): isMentioned = True if isMentioned: - colors = "".join(regex.findall("".join(words[:i+1]))) # join all color codes used upto this word - rec_words[i] = colorify("&r&a<&6") + stripcolors(word) + colorify("&r&a>&r") + colors # extra fancy highlight + # join all color codes used upto this word + colors = "".join(colors_reg.findall("".join(words[:i+1]))) + # highlight word containing mention, then apply all previous color codes + rec_words[i] = colorify("&r&a&n") + stripcolors(word) + colorify("&r") + colors # player was mentioned if rec_words != words: