summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2010-10-17 03:48:50 +0800
committerLance Stout <lancestout@gmail.com>2010-10-17 09:01:52 +0800
commitd9e7f555e6e313b590ea3c35577c5dbbbb5b5a59 (patch)
treed55d746f828184933d8f0aaaa3582a7218fd8640
parent2755d732a4e2843b4a685ec0ef57ee0f7c0f685f (diff)
downloadslixmpp-d9e7f555e6e313b590ea3c35577c5dbbbb5b5a59.tar.gz
slixmpp-d9e7f555e6e313b590ea3c35577c5dbbbb5b5a59.tar.bz2
slixmpp-d9e7f555e6e313b590ea3c35577c5dbbbb5b5a59.tar.xz
slixmpp-d9e7f555e6e313b590ea3c35577c5dbbbb5b5a59.zip
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.
-rw-r--r--sleekxmpp/plugins/xep_0045.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/sleekxmpp/plugins/xep_0045.py b/sleekxmpp/plugins/xep_0045.py
index de9b0944..7c06ca8b 100644
--- a/sleekxmpp/plugins/xep_0045.py
+++ b/sleekxmpp/plugins/xep_0045.py
@@ -195,7 +195,7 @@ 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=None, password='', wait=False, pstatus=None, pshow=None):
""" Join the specified room, requesting 'maxhistory' lines of history.
"""
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.text = password
x.append(passelement)
- history = ET.Element('history')
- history.attrib['maxstanzas'] = maxhistory
- x.append(history)
+ if maxhistory:
+ history = ET.Element('history')
+ if maxhistory == "0":
+ history.attrib['maxchars'] = maxhistory
+ else:
+ history.attrib['maxstanzas'] = maxhistory
+ x.append(history)
stanza.append(x)
if not wait:
self.xmpp.send(stanza)
@@ -267,10 +271,13 @@ class xep_0045(base.base_plugin):
msg.append(x)
self.xmpp.send(msg)
- def leaveMUC(self, room, nick):
+ def leaveMUC(self, room, nick, msg=''):
""" 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]
def getRoomConfig(self, room):