MUC leave message and MUC history request
It is now possible to ask for "any number of history stanzas" when joining a muc (with history=None). Also we use "maxchars" when asking NO history ("0") since it's a MUST in the XEP. And you can specify a message when leaving a MUC.
This commit is contained in:
parent
2755d732a4
commit
d9e7f555e6
1 changed files with 13 additions and 6 deletions
|
@ -195,7 +195,7 @@ 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=None, password='', wait=False, pstatus=None, pshow=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)
|
||||||
|
@ -204,9 +204,13 @@ class xep_0045(base.base_plugin):
|
||||||
passelement = ET.Element('password')
|
passelement = ET.Element('password')
|
||||||
passelement.text = password
|
passelement.text = password
|
||||||
x.append(passelement)
|
x.append(passelement)
|
||||||
history = ET.Element('history')
|
if maxhistory:
|
||||||
history.attrib['maxstanzas'] = maxhistory
|
history = ET.Element('history')
|
||||||
x.append(history)
|
if maxhistory == "0":
|
||||||
|
history.attrib['maxchars'] = maxhistory
|
||||||
|
else:
|
||||||
|
history.attrib['maxstanzas'] = maxhistory
|
||||||
|
x.append(history)
|
||||||
stanza.append(x)
|
stanza.append(x)
|
||||||
if not wait:
|
if not wait:
|
||||||
self.xmpp.send(stanza)
|
self.xmpp.send(stanza)
|
||||||
|
@ -267,10 +271,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):
|
def leaveMUC(self, room, nick, msg=''):
|
||||||
""" Leave the specified room.
|
""" Leave the specified room.
|
||||||
"""
|
"""
|
||||||
self.xmpp.sendPresence(pshow='unavailable', pto="%s/%s" % (room, nick))
|
if msg:
|
||||||
|
self.xmpp.sendPresence(pshow='unavailable', pto="%s/%s" % (room, nick), pstatus=msg)
|
||||||
|
else:
|
||||||
|
self.xmpp.sendPresence(pshow='unavailable', pto="%s/%s" % (room, nick))
|
||||||
del self.rooms[room]
|
del self.rooms[room]
|
||||||
|
|
||||||
def getRoomConfig(self, room):
|
def getRoomConfig(self, room):
|
||||||
|
|
Loading…
Reference in a new issue