Fix MUC methods to optionally specify the sending JID.
Should fix issue #107
This commit is contained in:
parent
335dc2927b
commit
87999333cb
1 changed files with 9 additions and 7 deletions
|
@ -223,10 +223,10 @@ class xep_0045(base.base_plugin):
|
||||||
return False
|
return False
|
||||||
return True
|
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.
|
""" 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')
|
x = ET.Element('{http://jabber.org/protocol/muc}x')
|
||||||
if password:
|
if password:
|
||||||
passelement = ET.Element('password')
|
passelement = ET.Element('password')
|
||||||
|
@ -272,7 +272,7 @@ class xep_0045(base.base_plugin):
|
||||||
return False
|
return False
|
||||||
return True
|
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."""
|
""" Change room affiliation."""
|
||||||
if affiliation not in ('outcast', 'member', 'admin', 'owner', 'none'):
|
if affiliation not in ('outcast', 'member', 'admin', 'owner', 'none'):
|
||||||
raise TypeError
|
raise TypeError
|
||||||
|
@ -284,6 +284,7 @@ class xep_0045(base.base_plugin):
|
||||||
query.append(item)
|
query.append(item)
|
||||||
iq = self.xmpp.makeIqSet(query)
|
iq = self.xmpp.makeIqSet(query)
|
||||||
iq['to'] = room
|
iq['to'] = room
|
||||||
|
iq['from'] = ifrom
|
||||||
# For now, swallow errors to preserve existing API
|
# For now, swallow errors to preserve existing API
|
||||||
try:
|
try:
|
||||||
result = iq.send()
|
result = iq.send()
|
||||||
|
@ -307,13 +308,13 @@ class xep_0045(base.base_plugin):
|
||||||
msg.append(x)
|
msg.append(x)
|
||||||
self.xmpp.send(msg)
|
self.xmpp.send(msg)
|
||||||
|
|
||||||
def leaveMUC(self, room, nick, msg=''):
|
def leaveMUC(self, room, nick, msg='', pfrom=None):
|
||||||
""" Leave the specified room.
|
""" Leave the specified room.
|
||||||
"""
|
"""
|
||||||
if msg:
|
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:
|
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]
|
del self.rooms[room]
|
||||||
|
|
||||||
def getRoomConfig(self, room, ifrom=''):
|
def getRoomConfig(self, room, ifrom=''):
|
||||||
|
@ -332,12 +333,13 @@ class xep_0045(base.base_plugin):
|
||||||
raise ValueError
|
raise ValueError
|
||||||
return self.xmpp.plugin['xep_0004'].buildForm(form)
|
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')
|
query = ET.Element('{http://jabber.org/protocol/muc#owner}query')
|
||||||
x = ET.Element('{jabber:x:data}x', type='cancel')
|
x = ET.Element('{jabber:x:data}x', type='cancel')
|
||||||
query.append(x)
|
query.append(x)
|
||||||
iq = self.xmpp.makeIqSet(query)
|
iq = self.xmpp.makeIqSet(query)
|
||||||
iq['to'] = room
|
iq['to'] = room
|
||||||
|
iq['from'] = ifrom
|
||||||
iq.send()
|
iq.send()
|
||||||
|
|
||||||
def setRoomConfig(self, room, config, ifrom=''):
|
def setRoomConfig(self, room, config, ifrom=''):
|
||||||
|
|
Loading…
Reference in a new issue