summaryrefslogtreecommitdiff
path: root/poezio/multiuserchat.py
diff options
context:
space:
mode:
Diffstat (limited to 'poezio/multiuserchat.py')
-rw-r--r--poezio/multiuserchat.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/poezio/multiuserchat.py b/poezio/multiuserchat.py
index a58883c6..ee596a0f 100644
--- a/poezio/multiuserchat.py
+++ b/poezio/multiuserchat.py
@@ -13,6 +13,7 @@ slix plugin
from xml.etree import cElementTree as ET
from poezio.common import safeJID
+from poezio import mam
from slixmpp import JID
from slixmpp.exceptions import IqError, IqTimeout
import logging
@@ -118,16 +119,27 @@ def join_groupchat(core,
passelement = ET.Element('password')
passelement.text = passwd
x.append(passelement)
- if seconds is not None:
- history = ET.Element('{http://jabber.org/protocol/muc}history')
- history.attrib['seconds'] = str(seconds)
- x.append(history)
- stanza.append(x)
- core.events.trigger('joining_muc', stanza)
- to = stanza["to"]
- stanza.send()
- xmpp.plugin['xep_0045'].rooms[jid] = {}
- xmpp.plugin['xep_0045'].our_nicks[jid] = to.resource
+ def on_disco(iq):
+ if 'urn:xmpp:mam:2' in iq['disco_info'].get_features():
+ history = ET.Element('{http://jabber.org/protocol/muc}history')
+ history.attrib['seconds'] = str(0)
+ x.append(history)
+ mam.mam_scroll(core.tabs.current_tab)
+ elif seconds is not None:
+ history = ET.Element('{http://jabber.org/protocol/muc}history')
+ history.attrib['seconds'] = str(seconds)
+ x.append(history)
+ stanza.append(x)
+ core.events.trigger('joining_muc', stanza)
+ to = stanza["to"]
+ stanza.send()
+ xmpp.plugin['xep_0045'].rooms[jid] = {}
+ xmpp.plugin['xep_0045'].our_nicks[jid] = to.resource
+
+ try:
+ xmpp.plugin['xep_0030'].get_info(jid=jid, callback=on_disco)
+ except (IqError, IqTimeout):
+ return core.information('Failed to retrieve messages', 'Error')
def leave_groupchat(xmpp, jid, own_nick, msg):