Disabled the history of MUC(from 0045) if the MUC supports MAM.

This commit is contained in:
Madhur Garg 2019-08-11 23:09:51 +05:30
parent c5ef5b0421
commit 4818210a63

View file

@ -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):