summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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):
"""