summaryrefslogtreecommitdiff
path: root/src/multiuserchat.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-04-26 14:05:28 +0200
committermathieui <mathieui@mathieui.net>2014-04-26 14:05:28 +0200
commit1f0ff4f0c30f5326e1b36ff03ebf83ac85239e89 (patch)
tree77aa90b2a0a7b3a8fec744b7c45f817ccd593e62 /src/multiuserchat.py
parent4c4e2083a6f4cab94b5cf63620e7a1be66c82817 (diff)
downloadpoezio-1f0ff4f0c30f5326e1b36ff03ebf83ac85239e89.tar.gz
poezio-1f0ff4f0c30f5326e1b36ff03ebf83ac85239e89.tar.bz2
poezio-1f0ff4f0c30f5326e1b36ff03ebf83ac85239e89.tar.xz
poezio-1f0ff4f0c30f5326e1b36ff03ebf83ac85239e89.zip
Fix #2444 (implement room destroy)
- destroy the current room if no parameter - destroy the room given as a parameter if any - no reason or alt room because it would be ambiguous in a command (implementation ideas welcome)
Diffstat (limited to 'src/multiuserchat.py')
-rw-r--r--src/multiuserchat.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/multiuserchat.py b/src/multiuserchat.py
index d1921100..ccf33ed1 100644
--- a/src/multiuserchat.py
+++ b/src/multiuserchat.py
@@ -11,6 +11,7 @@ Add some facilities that are not available on the XEP_0045
sleek plugin
"""
+from gettext import gettext as _
from xml.etree import cElementTree as ET
from common import safeJID
@@ -18,6 +19,36 @@ import logging
log = logging.getLogger(__name__)
NS_MUC_ADMIN = 'http://jabber.org/protocol/muc#admin'
+NS_MUC_OWNER = 'http://jabber.org/protocol/muc#owner'
+
+
+def destroy_room(xmpp, room, reason='', altroom=''):
+ """
+ destroy a room
+ """
+ room = safeJID(room)
+ if not room:
+ return False
+ iq = xmpp.make_iq_set()
+ iq['to'] = room
+ query = ET.Element('{%s}query' % NS_MUC_OWNER)
+ destroy = ET.Element('{%s}destroy' % NS_MUC_OWNER)
+ if altroom:
+ destroy.attrib['jid'] = altroom
+ if reason:
+ xreason = ET.Element('{%s}reason' % NS_MUC_OWNER)
+ xreason.text = reason
+ destroy.append(xreason)
+ query.append(destroy)
+ iq.append(query)
+ def callback(iq):
+ if not iq or iq['type'] == 'error':
+ xmpp.core.information(_('Unable to destroy room %s') % room,
+ _('Info'))
+ else:
+ xmpp.core.information(_('Room %s destroyed') % room, _('Info'))
+ iq.send(block=False, callback=callback)
+ return True
def send_private_message(xmpp, jid, line):
"""