21
21
#
22
22
#
23
23
# History:
24
+ # 2023-10-16: Sébastien Helleu <[email protected] >
25
+ # version 31: use info "irc_nick_color" on IRC buffers with WeeChat >= 4.1.0
24
26
# 2022-11-07: mva
25
27
# version 30: add ":" and "," to VALID_NICK regexp,
26
28
# to don't reset colorization in input_line
96
98
97
99
SCRIPT_NAME = "colorize_nicks"
98
100
SCRIPT_AUTHOR = "xt <[email protected] >"
99
- SCRIPT_VERSION = "30 "
101
+ SCRIPT_VERSION = "31 "
100
102
SCRIPT_LICENSE = "GPL"
101
103
SCRIPT_DESC = "Use the weechat nick colors in the chat area"
102
104
@@ -171,12 +173,17 @@ def colorize_config_read():
171
173
global colorize_config_file
172
174
return weechat .config_read (colorize_config_file )
173
175
174
- def colorize_nick_color (nick , my_nick ):
176
+ def colorize_nick_color (buffer , nick , my_nick ):
175
177
''' Retrieve nick color from weechat. '''
176
178
if nick == my_nick :
177
179
return w .color (w .config_string (w .config_get ('weechat.color.chat_nick_self' )))
178
180
else :
179
- return w .info_get ('nick_color' , nick )
181
+ if w .buffer_get_string (buffer , 'plugin' ) == 'irc' \
182
+ and int (w .info_get ('version_number' , '' ) or 0 ) >= 0x4010000 :
183
+ server = w .buffer_get_string (buffer , 'localvar_server' )
184
+ return w .info_get ('irc_nick_color' , '%s,%s' % (server , nick ))
185
+ else :
186
+ return w .info_get ('nick_color' , nick )
180
187
181
188
def colorize_cb (data , modifier , modifier_data , line ):
182
189
''' Callback that does the colorizing, and returns new line if changed '''
@@ -343,7 +350,7 @@ def populate_nicks(*args):
343
350
continue
344
351
345
352
nick = w .infolist_string (nicklist , 'name' )
346
- nick_color = colorize_nick_color (nick , my_nick )
353
+ nick_color = colorize_nick_color (buffer_ptr , nick , my_nick )
347
354
348
355
colored_nicks [buffer_ptr ][nick ] = nick_color
349
356
@@ -365,7 +372,7 @@ def add_nick(data, signal, type_data):
365
372
colored_nicks [pointer ] = {}
366
373
367
374
my_nick = w .buffer_get_string (pointer , 'localvar_nick' )
368
- nick_color = colorize_nick_color (nick , my_nick )
375
+ nick_color = colorize_nick_color (pointer , nick , my_nick )
369
376
370
377
colored_nicks [pointer ][nick ] = nick_color
371
378
0 commit comments