summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-10-10 11:31:03 -0400
committerLance Stout <lancestout@gmail.com>2011-10-10 11:31:03 -0400
commit87999333cba548b52d112fc49ba4b621b2955e7e (patch)
treee625366a32fbdcc8f42b488876718ea890112b51
parent335dc2927bf874aa3ee3d4154257040b3b59db1a (diff)
downloadslixmpp-87999333cba548b52d112fc49ba4b621b2955e7e.tar.gz
slixmpp-87999333cba548b52d112fc49ba4b621b2955e7e.tar.bz2
slixmpp-87999333cba548b52d112fc49ba4b621b2955e7e.tar.xz
slixmpp-87999333cba548b52d112fc49ba4b621b2955e7e.zip
Fix MUC methods to optionally specify the sending JID.
Should fix issue #107
-rw-r--r--sleekxmpp/plugins/xep_0045.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/sleekxmpp/plugins/xep_0045.py b/sleekxmpp/plugins/xep_0045.py
index 8bf67e1d..45f16110 100644
--- a/sleekxmpp/plugins/xep_0045.py
+++ b/sleekxmpp/plugins/xep_0045.py
@@ -223,10 +223,10 @@ class xep_0045(base.base_plugin):
return False
return True
- def joinMUC(self, room, nick, maxhistory="0", password='', wait=False, pstatus=None, pshow=None):
+ def joinMUC(self, room, nick, maxhistory="0", password='', wait=False, pstatus=None, pshow=None, pfrom=None):
""" Join the specified room, requesting 'maxhistory' lines of history.
"""
- stanza = self.xmpp.makePresence(pto="%s/%s" % (room, nick), pstatus=pstatus, pshow=pshow)
+ stanza = self.xmpp.makePresence(pto="%s/%s" % (room, nick), pstatus=pstatus, pshow=pshow, pfrom=pfrom)
x = ET.Element('{http://jabber.org/protocol/muc}x')
if password:
passelement = ET.Element('password')
@@ -272,7 +272,7 @@ class xep_0045(base.base_plugin):
return False
return True
- def setAffiliation(self, room, jid=None, nick=None, affiliation='member'):
+ def setAffiliation(self, room, jid=None, nick=None, affiliation='member', ifrom=None):
""" Change room affiliation."""
if affiliation not in ('outcast', 'member', 'admin', 'owner', 'none'):
raise TypeError
@@ -284,6 +284,7 @@ class xep_0045(base.base_plugin):
query.append(item)
iq = self.xmpp.makeIqSet(query)
iq['to'] = room
+ iq['from'] = ifrom
# For now, swallow errors to preserve existing API
try:
result = iq.send()
@@ -307,13 +308,13 @@ class xep_0045(base.base_plugin):
msg.append(x)
self.xmpp.send(msg)
- def leaveMUC(self, room, nick, msg=''):
+ def leaveMUC(self, room, nick, msg='', pfrom=None):
""" Leave the specified room.
"""
if msg:
- self.xmpp.sendPresence(pshow='unavailable', pto="%s/%s" % (room, nick), pstatus=msg)
+ self.xmpp.sendPresence(pshow='unavailable', pto="%s/%s" % (room, nick), pstatus=msg, pfrom=pfrom)
else:
- self.xmpp.sendPresence(pshow='unavailable', pto="%s/%s" % (room, nick))
+ self.xmpp.sendPresence(pshow='unavailable', pto="%s/%s" % (room, nick), pfrom=pfrom)
del self.rooms[room]
def getRoomConfig(self, room, ifrom=''):
@@ -332,12 +333,13 @@ class xep_0045(base.base_plugin):
raise ValueError
return self.xmpp.plugin['xep_0004'].buildForm(form)
- def cancelConfig(self, room):
+ def cancelConfig(self, room, ifrom=None):
query = ET.Element('{http://jabber.org/protocol/muc#owner}query')
x = ET.Element('{jabber:x:data}x', type='cancel')
query.append(x)
iq = self.xmpp.makeIqSet(query)
iq['to'] = room
+ iq['from'] = ifrom
iq.send()
def setRoomConfig(self, room, config, ifrom=''):