Merge branch 'feature/xep0392-based-on-nickname' of https://github.com/horazont/poezio
This commit is contained in:
commit
d4bc3b543e
2 changed files with 12 additions and 9 deletions
|
@ -650,32 +650,36 @@ class MucTab(ChatTab):
|
||||||
def on_user_nick_change(self, presence, user, from_nick, from_room):
|
def on_user_nick_change(self, presence, user, from_nick, from_room):
|
||||||
new_nick = presence.xml.find('{%s}x/{%s}item' %
|
new_nick = presence.xml.find('{%s}x/{%s}item' %
|
||||||
(NS_MUC_USER, NS_MUC_USER)).attrib['nick']
|
(NS_MUC_USER, NS_MUC_USER)).attrib['nick']
|
||||||
|
old_color = user.color
|
||||||
if user.nick == self.own_nick:
|
if user.nick == self.own_nick:
|
||||||
self.own_nick = new_nick
|
self.own_nick = new_nick
|
||||||
# also change our nick in all private discussions of this room
|
# also change our nick in all private discussions of this room
|
||||||
self.core.handler.on_muc_own_nickchange(self)
|
self.core.handler.on_muc_own_nickchange(self)
|
||||||
|
user.change_nick(new_nick)
|
||||||
else:
|
else:
|
||||||
color = config.get_by_tabname(new_nick, 'muc_colors')
|
user.change_nick(new_nick)
|
||||||
if color != '':
|
deterministic = config.get_by_tabname(
|
||||||
deterministic = config.get_by_tabname(
|
'deterministic_nick_colors', self.name)
|
||||||
'deterministic_nick_colors', self.name)
|
color = config.get_by_tabname(new_nick, 'muc_colors') or None
|
||||||
|
if color or deterministic:
|
||||||
user.change_color(color, deterministic)
|
user.change_color(color, deterministic)
|
||||||
user.change_nick(new_nick)
|
|
||||||
self.users.remove(user)
|
self.users.remove(user)
|
||||||
bisect.insort_left(self.users, user)
|
bisect.insort_left(self.users, user)
|
||||||
|
|
||||||
if config.get_by_tabname('display_user_color_in_join_part',
|
if config.get_by_tabname('display_user_color_in_join_part',
|
||||||
self.general_jid):
|
self.general_jid):
|
||||||
color = dump_tuple(user.color)
|
color = dump_tuple(user.color)
|
||||||
|
old_color = dump_tuple(old_color)
|
||||||
else:
|
else:
|
||||||
color = 3
|
old_color = color = 3
|
||||||
info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
|
info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
|
||||||
self.add_message(
|
self.add_message(
|
||||||
'\x19%(color)s}%(old)s\x19%(info_col)s} is'
|
'\x19%(old_color)s}%(old)s\x19%(info_col)s} is'
|
||||||
' now known as \x19%(color)s}%(new)s' % {
|
' now known as \x19%(color)s}%(new)s' % {
|
||||||
'old': from_nick,
|
'old': from_nick,
|
||||||
'new': new_nick,
|
'new': new_nick,
|
||||||
'color': color,
|
'color': color,
|
||||||
|
'old_color': old_color,
|
||||||
'info_col': info_col
|
'info_col': info_col
|
||||||
},
|
},
|
||||||
typ=2)
|
typ=2)
|
||||||
|
|
|
@ -56,8 +56,7 @@ class User(object):
|
||||||
if theme.ccg_palette:
|
if theme.ccg_palette:
|
||||||
# use XEP-0392 CCG
|
# use XEP-0392 CCG
|
||||||
fg_color = colors.ccg_text_to_color(
|
fg_color = colors.ccg_text_to_color(
|
||||||
theme.ccg_palette, self.jid.bare
|
theme.ccg_palette, self.nick)
|
||||||
if self.jid and self.jid.bare else self.nick)
|
|
||||||
self.color = fg_color, -1
|
self.color = fg_color, -1
|
||||||
else:
|
else:
|
||||||
mod = len(theme.LIST_COLOR_NICKNAMES)
|
mod = len(theme.LIST_COLOR_NICKNAMES)
|
||||||
|
|
Loading…
Reference in a new issue