Skip to content

Commit c46d70a

Browse files
ncfavierflashcode
authored andcommitted
colorize_nicks.py 29: check nick for exclusion *after* stripping, decrease minimum length to 1
The first change is so that nicknames are checked for min_nick_length or blacklist *after* stripping e.g. the ":" address part. The second change is so that I can see my good friend `k` in colour.
1 parent 27f8930 commit c46d70a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

python/colorize_nicks.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#
2222
#
2323
# History:
24+
# 2022-07-11: ncfavier
25+
# version 29: check nick for exclusion *after* stripping
26+
# decrease minimum min_nick_length to 1
2427
# 2020-11-29: jess
2528
# version 28: fix ignore_tags having been broken by weechat 2.9 changes
2629
# 2020-05-09: Sébastien Helleu <[email protected]>
@@ -90,7 +93,7 @@
9093

9194
SCRIPT_NAME = "colorize_nicks"
9295
SCRIPT_AUTHOR = "xt <[email protected]>"
93-
SCRIPT_VERSION = "28"
96+
SCRIPT_VERSION = "29"
9497
SCRIPT_LICENSE = "GPL"
9598
SCRIPT_DESC = "Use the weechat nick colors in the chat area"
9699

@@ -138,7 +141,7 @@ def colorize_config_init():
138141
colorize_config_option["min_nick_length"] = weechat.config_new_option(
139142
colorize_config_file, section_look, "min_nick_length",
140143
"integer", "Minimum length nick to colorize", "",
141-
2, 20, "", "", 0, "", "", "", "", "", "")
144+
1, 20, "2", "2", 0, "", "", "", "", "", "")
142145
colorize_config_option["colorize_input"] = weechat.config_new_option(
143146
colorize_config_file, section_look, "colorize_input",
144147
"boolean", "Whether to colorize input", "", 0,
@@ -170,7 +173,7 @@ def colorize_nick_color(nick, my_nick):
170173
if nick == my_nick:
171174
return w.color(w.config_string(w.config_get('weechat.color.chat_nick_self')))
172175
else:
173-
return w.info_get('irc_nick_color', nick)
176+
return w.info_get('nick_color', nick)
174177

175178
def colorize_cb(data, modifier, modifier_data, line):
176179
''' Callback that does the colorizing, and returns new line if changed '''
@@ -206,9 +209,6 @@ def colorize_cb(data, modifier, modifier_data, line):
206209

207210
for words in valid_nick_re.findall(line):
208211
nick = words[1]
209-
# Check that nick is not ignored and longer than minimum length
210-
if len(nick) < min_length or nick in ignore_nicks:
211-
continue
212212

213213
# If the matched word is not a known nick, we try to match the
214214
# word without its first or last character (if not a letter).
@@ -225,6 +225,10 @@ def colorize_cb(data, modifier, modifier_data, line):
225225
if nick[:-1] in colored_nicks[buffer]:
226226
nick = nick[:-1]
227227

228+
# Check that nick is not ignored and longer than minimum length
229+
if len(nick) < min_length or nick in ignore_nicks:
230+
continue
231+
228232
# Check that nick is in the dictionary colored_nicks
229233
if nick in colored_nicks[buffer]:
230234
nick_color = colored_nicks[buffer][nick]

0 commit comments

Comments
 (0)