summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2013-05-11 00:33:06 +0200
committermathieui <mathieui@mathieui.net>2013-05-11 00:33:06 +0200
commit3d8c91dcb087520bbcc15aafb48bce1df3b5b833 (patch)
tree18ad8119b8b97f65b01449810214674a5604b49d /src
parent686352d22bc2973cdb9a003353a9811e5587d177 (diff)
downloadpoezio-3d8c91dcb087520bbcc15aafb48bce1df3b5b833.tar.gz
poezio-3d8c91dcb087520bbcc15aafb48bce1df3b5b833.tar.bz2
poezio-3d8c91dcb087520bbcc15aafb48bce1df3b5b833.tar.xz
poezio-3d8c91dcb087520bbcc15aafb48bce1df3b5b833.zip
Fix the reason in the ban message
Diffstat (limited to 'src')
-rw-r--r--src/multiuserchat.py6
-rw-r--r--src/tabs.py19
2 files changed, 20 insertions, 5 deletions
diff --git a/src/multiuserchat.py b/src/multiuserchat.py
index 386da341..013fd2cb 100644
--- a/src/multiuserchat.py
+++ b/src/multiuserchat.py
@@ -127,6 +127,12 @@ def set_user_affiliation(xmpp, muc_jid, affiliation, nick=None, jid=None, reason
item = ET.Element('{http://jabber.org/protocol/muc#admin}item', {'affiliation':affiliation, 'nick':nick})
else:
item = ET.Element('{http://jabber.org/protocol/muc#admin}item', {'affiliation':affiliation, 'jid':str(jid)})
+
+ if reason:
+ reason_item = ET.Element('{http://jabber.org/protocol/muc#admin}reason')
+ reason_item.text = reason
+ item.append(reason_item)
+
query.append(item)
iq = xmpp.makeIqSet(query)
iq['to'] = muc_jid
diff --git a/src/tabs.py b/src/tabs.py
index 8dfc8095..63c1558b 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -1153,15 +1153,24 @@ class MucTab(ChatTab):
"""
/ban <nick> [reason]
"""
+ def callback(iq):
+ if iq['type'] == 'error':
+ self.core.room_error(iq, self.get_name())
args = common.shell_split(arg)
if not args:
self.core.command_help('ban')
+ if len(args) > 1:
+ msg = args[1]
else:
- if len(args) > 1:
- msg = ' "%s"' %args[1]
- else:
- msg = ''
- self.command_affiliation('"'+args[0]+ '" outcast'+msg)
+ msg = ''
+ nick = args[0]
+
+ if nick in [user.nick for user in self.users]:
+ res = muc.set_user_affiliation(self.core.xmpp, self.get_name(), 'outcast', nick=nick, callback=callback, reason=msg)
+ else:
+ res = muc.set_user_affiliation(self.core.xmpp, self.get_name(), 'outcast', jid=safeJID(nick), callback=callback, reason=msg)
+ if not res:
+ self.core.information('Could not ban user', 'Error')
def command_role(self, arg):
"""