summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2011-11-01 17:14:43 +0100
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2011-11-01 17:14:43 +0100
commitdac8a12abff0ec7c8d3baec4eb73535040c9de9d (patch)
treef1197bf818746f5fa7ddf4549a14fa8e2c748e0c /src
parentecf3685db6234e9dc53a41d4635d092a48de37a4 (diff)
downloadpoezio-dac8a12abff0ec7c8d3baec4eb73535040c9de9d.tar.gz
poezio-dac8a12abff0ec7c8d3baec4eb73535040c9de9d.tar.bz2
poezio-dac8a12abff0ec7c8d3baec4eb73535040c9de9d.tar.xz
poezio-dac8a12abff0ec7c8d3baec4eb73535040c9de9d.zip
Add a config option that display the nick in join/part/status
change/etc. in that user color. Fixes #2282.
Diffstat (limited to 'src')
-rw-r--r--src/tabs.py41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/tabs.py b/src/tabs.py
index bc85a618..b8385747 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -907,14 +907,16 @@ class MucTab(ChatTab):
"""
When a new user joins the groupchat
"""
- room.users.append(User(from_nick, affiliation,
- show, status, role, jid))
+ user = User(from_nick, affiliation,
+ show, status, role, jid)
+ room.users.append(user)
hide_exit_join = config.get('hide_exit_join', -1)
if hide_exit_join != 0:
+ color = user.color[0] if config.get('display_user_color_in_join_part', '') == 'true' else 3
if not jid.full:
- room.add_message('\x194}%(spec)s \x193}%(nick)s\x195} joined the room' % {'nick':from_nick, 'spec':get_theme().CHAR_JOIN})
+ room.add_message('\x194}%(spec)s \x19%(color)d}%(nick)s\x195} joined the room' % {'nick':from_nick, 'color':color, 'spec':get_theme().CHAR_JOIN})
else:
- room.add_message('\x194}%(spec)s \x193}%(nick)s \x195}(\x194}%(jid)s\x195}) joined the room' % {'spec':get_theme().CHAR_JOIN, 'nick':from_nick, 'jid':jid.full})
+ room.add_message('\x194}%(spec)s \x19%(color)d}%(nick)s \x195}(\x194}%(jid)s\x195}) joined the room' % {'spec':get_theme().CHAR_JOIN, 'nick':from_nick, 'color':color, 'jid':jid.full})
self.core.on_user_rejoined_private_conversation(room.name, from_nick)
@@ -927,7 +929,8 @@ class MucTab(ChatTab):
if isinstance(_tab, PrivateTab) and JID(_tab.get_name()).bare == room.name:
_tab.get_room().own_nick = new_nick
user.change_nick(new_nick)
- room.add_message('\x193}%(old)s\x195} is now known as \x193}%(new)s' % {'old':from_nick, 'new':new_nick})
+ color = user.color[0] if config.get('display_user_color_in_join_part', '') == 'true' else 3
+ room.add_message('\x19%(color)d}%(old)s\x195} is now known as \x19%(color)d}%(new)s' % {'old':from_nick, 'new':new_nick, 'color':color})
# rename the private tabs if needed
self.core.rename_private_tabs(room.name, from_nick, new_nick)
@@ -949,10 +952,11 @@ class MucTab(ChatTab):
else:
kick_msg = _('\x191}%(spec)s \x193}You\x195} have been banned.') % {'spec':get_theme().CHAR_KICK}
else:
+ color = user.color[0] if config.get('display_user_color_in_join_part', '') == 'true' else 3
if by:
- kick_msg = _('\x191}%(spec)s \x193}%(nick)s\x195} has been banned by \x194}%(by)s') % {'spec':get_theme().CHAR_KICK, 'nick':from_nick, 'by':by}
+ kick_msg = _('\x191}%(spec)s \x19%(color)d}%(nick)s\x195} has been banned by \x194}%(by)s') % {'spec':get_theme().CHAR_KICK, 'nick':from_nick, 'color':color, 'by':by}
else:
- kick_msg = _('\x191}%(spec)s \x193}%(nick)s\x195} has been banned') % {'spec':get_theme().CHAR_KICK, 'nick':from_nick.replace('"', '\\"')}
+ kick_msg = _('\x191}%(spec)s \x19%(color)d}%(nick)s\x195} has been banned') % {'spec':get_theme().CHAR_KICK, 'nick':from_nick.replace('"', '\\"'), 'color':color}
if reason is not None and reason.text:
kick_msg += _('\x195} Reason: \x196}%(reason)s\x195}') % {'reason': reason.text}
room.add_message(kick_msg)
@@ -978,10 +982,11 @@ class MucTab(ChatTab):
if config.get('autorejoin', 'false') == 'true':
muc.join_groupchat(self.core.xmpp, room.name, room.own_nick)
else:
+ color = user.color[0] if config.get('display_user_color_in_join_part', '') == 'true' else 3
if by:
- kick_msg = _('\x191}%(spec)s \x193}%(nick)s\x195} has been kicked by \x193}%(by)s') % {'spec':get_theme().CHAR_KICK.replace('"', '\\"'), 'nick':from_nick.replace('"', '\\"'), 'by':by.replace('"', '\\"')}
+ kick_msg = _('\x191}%(spec)s \x19%(color)d}%(nick)s\x195} has been kicked by \x193}%(by)s') % {'spec':get_theme().CHAR_KICK.replace('"', '\\"'), 'nick':from_nick.replace('"', '\\"'), 'color':color, 'by':by.replace('"', '\\"')}
else:
- kick_msg = _('\x191}%(spec)s \x193}%(nick)s\x195} has been kicked') % {'spec':get_theme().CHAR_KICK, 'nick':from_nick.replace('"', '\\"')}
+ kick_msg = _('\x191}%(spec)s \x19%(color)d}%(nick)s\x195} has been kicked') % {'spec':get_theme().CHAR_KICK, 'nick':from_nick.replace('"', '\\"'), 'color':color}
if reason is not None and reason.text:
kick_msg += _('\x195} Reason: \x196}%(reason)s') % {'reason': reason.text}
room.add_message(kick_msg)
@@ -999,10 +1004,12 @@ class MucTab(ChatTab):
self.core.doupdate()
hide_exit_join = config.get('hide_exit_join', -1) if config.get('hide_exit_join', -1) >= -1 else -1
if hide_exit_join == -1 or user.has_talked_since(hide_exit_join):
+ log.debug("\n\nALLO: USERCOLOR: %s\n\n" % user.color.__repr__())
+ color = user.color[0] if config.get('display_user_color_in_join_part', '') == 'true' else 3
if not jid.full:
- leave_msg = _('\x191}%(spec)s \x193}%(nick)s\x195} has left the room') % {'nick':from_nick, 'spec':get_theme().CHAR_QUIT}
+ leave_msg = _('\x191}%(spec)s \x19%(color)d}%(nick)s\x195} has left the room') % {'nick':from_nick, 'color':color, 'spec':get_theme().CHAR_QUIT}
else:
- leave_msg = _('\x191}%(spec)s \x193}%(nick)s\x195} (\x194}%(jid)s\x195}) has left the room') % {'spec':get_theme().CHAR_QUIT, 'nick':from_nick, 'jid':jid.full}
+ leave_msg = _('\x191}%(spec)s \x19%(color)d}%(nick)s\x195} (\x194}%(jid)s\x195}) has left the room') % {'spec':get_theme().CHAR_QUIT, 'nick':from_nick, 'color':color, 'jid':jid.full}
if status:
leave_msg += ' (%s)' % status
room.add_message(leave_msg)
@@ -1016,7 +1023,11 @@ class MucTab(ChatTab):
# build the message
display_message = False # flag to know if something significant enough
# to be displayed has changed
- msg = _('\x193}%s\x195} changed: ')% from_nick.replace('"', '\\"')
+ color = user.color[0] if config.get('display_user_color_in_join_part', '') == 'true' else 3
+ if from_nick == room.own_nick:
+ msg = _('\x193d}You\x195} changed: ')
+ else:
+ msg = _('\x19%(color)d}%(nick)s\x195} changed: ') % {'nick': from_nick.replace('"', '\\"'), 'color': color}
if show not in SHOW_NAME:
self.core.information("%s from room %s sent an invalid show: %s" %\
(from_nick, from_room, show), "warning")
@@ -1040,7 +1051,9 @@ class MucTab(ChatTab):
if not display_message:
return
msg = msg[:-2] # remove the last ", "
- hide_status_change = config.get('hide_status_change', -1) if config.get('hide_status_change', -1) >= -1 else -1
+ hide_status_change = config.get('hide_status_change', -1)
+ if hide_status_change < -1:
+ hide_status_change = -1
if (hide_status_change == -1 or \
user.has_talked_since(hide_status_change) or\
user.nick == room.own_nick)\
@@ -1237,7 +1250,7 @@ class PrivateTab(ChatTab):
The user (or at least someone with the same nick) came back in the MUC
"""
self.activate()
- self.get_room().add_message('\x194}%(spec)s \x193}%(nick)s\x195} joined the room' % {'nick':nick, 'spec':get_theme().CHAR_JOIN})
+ self.get_room().add_message('\x194}%(spec)s \x19%(color)d}%(nick)s\x195} joined the room' % {'nick':nick, 'color':user.color, 'spec':get_theme().CHAR_JOIN})
if self.core.current_tab() is self:
self.refresh()
self.core.doupdate()