Commit 0ae1ee2f authored by Célestin Matte's avatar Célestin Matte

Add nick_color_aliases (default: true), to look for color of aliases

parent 1bbdab7f
......@@ -374,6 +374,9 @@ user_list_sort = desc
# If the MUC nicks should receive a fixed color based on their text or not
deterministic_nick_colors = true
# If _nick, nick_, _nick_, nick__ etc. should have the same color as nick
nick_color_aliases = true
# The nick of people who join, part, change their status, etc. in a MUC will
# be displayed using their nick color if true.
display_user_color_in_join_part = true
......
......@@ -528,6 +528,15 @@ or the way messages are displayed.
The value of this option affects the behavior of :term:`/recolor`.
nick_color_aliases
**Default value:** ``true``
Automatically search for color of nick aliases. For example, if nick is
set to red, _nick, nick_, _nick_, nick__ etc. will have the same color.
Aliases colors are checked first, so that it is still possible to have
different colors for nick_ and nick.
vertical_tab_list_size
**Default value:** ``20``
......@@ -755,7 +764,6 @@ or the way messages are displayed.
be displayed in that color. This color won't be changed by the recolor
command.
User Interaction
~~~~~~~~~~~~~~~~
......
......@@ -43,6 +43,7 @@ DEFAULT_CONFIG = {
'custom_port': '',
'default_nick': '',
'deterministic_nick_colors': True,
'nick_color_aliases': True,
'display_activity_notifications': False,
'display_gaming_notifications': False,
'display_mood_notifications': False,
......
......@@ -426,7 +426,7 @@ class MucTab(ChatTab):
for user in self.users:
if user.nick == self.own_nick:
continue
color = config.get_by_tabname(user.nick, 'muc_colors')
color = self.search_for_color(user.nick)
if color != '':
continue
user.set_deterministic_color()
......@@ -444,7 +444,7 @@ class MucTab(ChatTab):
# search our own user, to remove it from the list
# Also remove users whose color is fixed
for user in full_sorted_users:
color = config.get_by_tabname(user.nick, 'muc_colors')
color = self.search_for_color(user.nick)
if user.nick == self.own_nick:
sorted_users.remove(user)
user.color = get_theme().COLOR_OWN_NICK
......@@ -1068,7 +1068,7 @@ class MucTab(ChatTab):
jid = presence['muc']['jid']
typ = presence['type']
deterministic = config.get_by_tabname('deterministic_nick_colors', self.name)
color = config.get_by_tabname(from_nick, 'muc_colors')
color = self.search_for_color(from_nick)
if not self.joined: # user in the room BEFORE us.
# ignore redondant presence message, see bug #1509
if (from_nick not in [user.nick for user in self.users]
......@@ -1670,3 +1670,19 @@ class MucTab(ChatTab):
self.core.refresh_window()
else: # Re-send a self-ping in a few seconds
self.enable_self_ping_event()
def search_for_color(self, nick):
"""
Search for the color of a nick in the config file.
Also, look at the colors of its possible aliases if nick_color_aliases
is set.
"""
color = config.get_by_tabname(nick, 'muc_colors')
if color != '':
return color
nick_color_aliases = config.get_by_tabname('nick_color_aliases', self.name)
if nick_color_aliases:
nick_alias = re.sub('^_*', '', nick)
nick_alias = re.sub('_*$', '', nick_alias)
color = config.get_by_tabname(nick_alias, 'muc_colors')
return color
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment