summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-01-23 23:01:53 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-01-23 23:01:53 +0100
commit4a84691228e1ccc34274522809b647a5074fdc44 (patch)
tree54bb92bdb47edc9935d61a09a185607aeaad2336 /src
parent333b80b5df2e83a076738c4e1f850985aa82b7a0 (diff)
downloadpoezio-4a84691228e1ccc34274522809b647a5074fdc44.tar.gz
poezio-4a84691228e1ccc34274522809b647a5074fdc44.tar.bz2
poezio-4a84691228e1ccc34274522809b647a5074fdc44.tar.xz
poezio-4a84691228e1ccc34274522809b647a5074fdc44.zip
Handle correctly the banning of a muc participant
Fixed #2112
Diffstat (limited to 'src')
-rw-r--r--src/core.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/core.py b/src/core.py
index f9a7d328..381ff8ab 100644
--- a/src/core.py
+++ b/src/core.py
@@ -364,6 +364,7 @@ class Core(object):
else:
change_nick = '303' in status_codes
kick = '307' in status_codes and typ == 'unavailable'
+ ban = '301' in status_codes and typ == 'unavailable'
user = room.get_user_by_name(from_nick)
# New user
if not user:
@@ -371,6 +372,8 @@ class Core(object):
# nick change
elif change_nick:
self.on_user_nick_change(room, presence, user, from_nick, from_room)
+ elif ban:
+ self.on_user_banned(room, presence, user, from_nick)
# kick
elif kick:
self.on_user_kicked(room, presence, user, from_nick)
@@ -413,9 +416,32 @@ class Core(object):
new_jid = JID(private_room.name).bare+'/'+new_nick
private_room.name = new_jid
+ def on_user_banned(self, room, presence, user, from_nick):
+ """
+ When someone is banned from a muc
+ """
+ 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 is not None else None
+ if from_nick == room.own_nick: # we are banned
+ room.disconnect()
+ if by:
+ kick_msg = _('%(spec)s [You] have been banned by "[%(by)s]"') % {'spec': theme.CHAR_KICK.replace('"', '\\"'), 'by':by}
+ else:
+ kick_msg = _('%(spec)s [You] have been banned.') % {'spec':theme.CHAR_KICK.replace('"', '\\"')}
+ else:
+ if by:
+ kick_msg = _('%(spec)s "[%(nick)s]" has been banned by "[%(by)s]"') % {'spec':theme.CHAR_KICK.replace('"', '\\"'), 'nick':from_nick.replace('"', '\\"'), 'by':by.replace('"', '\\"')}
+ else:
+ kick_msg = _('%(spec)s "[%(nick)s]" has been banned') % {'spec':theme.CHAR_KICK, 'nick':from_nick.replace('"', '\\"')}
+ if reason is not None and reason.text:
+ kick_msg += _(' Reason: %(reason)s') % {'reason': reason.text}
+ self.add_message_to_text_buffer(room, kick_msg, colorized=True)
+
def on_user_kicked(self, room, presence, user, from_nick):
"""
- When someone is kicked
+ When someone is kicked from a muc
"""
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')