From 1ef7d588265a94ae2cd8775b0c124041b0e0d7c4 Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Thu, 2 Sep 2010 01:22:22 +0000 Subject: [PATCH] little cleanup on user status change --- src/gui.py | 60 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/src/gui.py b/src/gui.py index e6984fe5..3385d971 100644 --- a/src/gui.py +++ b/src/gui.py @@ -239,33 +239,7 @@ class Gui(object): self.on_user_leave_groupchat(room, user, jid, status, from_nick, from_room) # status change else: - # build the message - msg = _('%s changed his/her status: ')% from_nick - if affiliation != user.affiliation: - msg += _('affiliation: %s,') % affiliation - if role != user.role: - msg += _('role: %s,') % role - if show != user.show and show in SHOW_NAME.keys(): - msg += _('show: %s,') % SHOW_NAME[show] - if status != user.status: - msg += _('status: %s,') % status - msg = msg[:-1] # remove the last "," - hide_status_change = config.get('hide_status_change', -1) if config.get('hide_status_change', -1) >= -1 else -1 - if (hide_status_change == -1 or \ - user.has_talked_since(hide_status_change) or\ - user.nick == room.own_nick)\ - and\ - (affiliation != user.affiliation or\ - role != user.role or\ - show != user.show or\ - status != user.status): - # display the message in the room - self.add_message_to_room(room, msg) - private_room = self.get_room_by_name('%s/%s' % (from_room, from_nick)) - if private_room: # display the message in private - self.add_message_to_room(private_room, msg) - # finally, effectively change the user status - user.update(affiliation, show, status, role) + self.on_user_change_status(room, user, from_nick, from_room, affiliation, role, show, status) if room == self.current_room(): self.window.user_win.refresh(room.users) self.window.input.refresh() @@ -349,6 +323,38 @@ class Gui(object): else: self.add_message_to_room(private_room, _('%(spec)s [%(nick)s] has left the room (%(status)s)') % {'nick':from_nick, 'spec':theme.CHAR_QUIT, 'status': status}, colorized=True) + def on_user_change_status(self, room, user, from_nick, from_room, affiliation, role, show, status): + """ + When an user changes her status + """ + # build the message + msg = _('%s changed his/her status: ')% from_nick + if affiliation != user.affiliation: + msg += _('affiliation: %s,') % affiliation + if role != user.role: + msg += _('role: %s,') % role + if show != user.show and show in SHOW_NAME.keys(): + msg += _('show: %s,') % SHOW_NAME[show] + if status != user.status: + msg += _('status: %s,') % status + msg = msg[:-1] # remove the last "," + hide_status_change = config.get('hide_status_change', -1) if config.get('hide_status_change', -1) >= -1 else -1 + if (hide_status_change == -1 or \ + user.has_talked_since(hide_status_change) or\ + user.nick == room.own_nick)\ + and\ + (affiliation != user.affiliation or\ + role != user.role or\ + show != user.show or\ + status != user.status): + # display the message in the room + self.add_message_to_room(room, msg) + private_room = self.get_room_by_name('%s/%s' % (from_room, from_nick)) + if private_room: # display the message in private + self.add_message_to_room(private_room, msg) + # finally, effectively change the user status + user.update(affiliation, show, status, role) + def on_message(self, message): """ When receiving private message from a muc OR a normal message