diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-09-02 01:16:17 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-09-02 01:16:17 +0000 |
commit | addde0121a09c0a36c8422a00bd4f9414cf19ed8 (patch) | |
tree | 815cb5b3fdab8b14e54c8986b83262ad0e695ad7 /src | |
parent | ed39518bf6f74fffb53cbe46f23577d3dfc0cbd0 (diff) | |
download | poezio-addde0121a09c0a36c8422a00bd4f9414cf19ed8.tar.gz poezio-addde0121a09c0a36c8422a00bd4f9414cf19ed8.tar.bz2 poezio-addde0121a09c0a36c8422a00bd4f9414cf19ed8.tar.xz poezio-addde0121a09c0a36c8422a00bd4f9414cf19ed8.zip |
little cleanup on kick
Diffstat (limited to 'src')
-rw-r--r-- | src/gui.py | 51 |
1 files changed, 28 insertions, 23 deletions
@@ -233,29 +233,7 @@ class Gui(object): self.on_user_nick_change(room, presence, user, from_nick, from_room) # kick elif kick: - room.users.remove(user) - by = presence.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}item/{http://jabber.org/protocol/muc#user}actor') - reason = presence.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}item/{http://jabber.org/protocol/muc#user}reason') - by = by.attrib['jid'] if by else '' - reason = reason.text# if reason else '' - if from_nick == room.own_nick: # we are kicked - room.disconnect() - if by: - kick_msg = _("%(spec) [You] have been kicked by [%(by)s].") % {'spec': theme.CHAR_KICK, 'by':by} - else: - kick_msg = _("%(spec)s [You] have been kicked.") % {'spec':theme.CHAR_KICK} - # try to auto-rejoin - if config.get('autorejoin', 'false') == 'true': - muc.join_groupchat(self.xmpp, room.name, room.own_nick) - else: - if by: - kick_msg = _("%(spec)s [%(nick)s] has been kicked by %(by)s.") % {'spec':theme.CHAR_KICK, 'nick':from_nick, 'by':by} - else: - kick_msg = _("%(spec)s [%(nick)s] has been kicked") % {'spec':theme.CHAR_KICK, 'nick':from_nick} - if reason: - kick_msg += _(' Reason: %(reason)s') % {'reason': reason} - self.add_message_to_room(room, kick_msg, colorized=True) - + self.on_user_kicked(room, presence, user, from_nick) # user quit elif typ == 'unavailable': room.users.remove(user) @@ -338,6 +316,33 @@ class Gui(object): new_jid = private_room.name.split('/')[0]+'/'+new_nick private_room.jid = private_room.name = new_jid + def on_user_kicked(self, room, presence, user, from_nick): + """ + When someone is kicked + """ + room.users.remove(user) + by = presence.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}item/{http://jabber.org/protocol/muc#user}actor') + reason = presence.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}item/{http://jabber.org/protocol/muc#user}reason') + by = by.attrib['jid'] if by else '' + reason = reason.text# if reason else '' + if from_nick == room.own_nick: # we are kicked + room.disconnect() + if by: + kick_msg = _("%(spec) [You] have been kicked by [%(by)s].") % {'spec': theme.CHAR_KICK, 'by':by} + else: + kick_msg = _("%(spec)s [You] have been kicked.") % {'spec':theme.CHAR_KICK} + # try to auto-rejoin + if config.get('autorejoin', 'false') == 'true': + muc.join_groupchat(self.xmpp, room.name, room.own_nick) + else: + if by: + kick_msg = _("%(spec)s [%(nick)s] has been kicked by %(by)s.") % {'spec':theme.CHAR_KICK, 'nick':from_nick, 'by':by} + else: + kick_msg = _("%(spec)s [%(nick)s] has been kicked") % {'spec':theme.CHAR_KICK, 'nick':from_nick} + if reason: + kick_msg += _(' Reason: %(reason)s') % {'reason': reason} + self.add_message_to_room(room, kick_msg, colorized=True) + def on_message(self, message): """ When receiving private message from a muc OR a normal message |