summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadhur Garg <madhurgarg96@gmail.com>2019-06-24 10:23:35 +0530
committerMadhur Garg <madhurgarg96@gmail.com>2019-08-22 00:54:25 +0530
commit4929c298e555d4fc13e0ffef9caf62e64e452804 (patch)
tree6a96851afedfe8a98faf43c6fc7567e30c8a38a9
parente3412f6d36afb0d9c599502f01fe65f367e3c626 (diff)
downloadpoezio-4929c298e555d4fc13e0ffef9caf62e64e452804.tar.gz
poezio-4929c298e555d4fc13e0ffef9caf62e64e452804.tar.bz2
poezio-4929c298e555d4fc13e0ffef9caf62e64e452804.tar.xz
poezio-4929c298e555d4fc13e0ffef9caf62e64e452804.zip
Removed extra connection
-rw-r--r--poezio/mam.py22
1 files changed, 5 insertions, 17 deletions
diff --git a/poezio/mam.py b/poezio/mam.py
index 6fc9f8e1..6a16c99b 100644
--- a/poezio/mam.py
+++ b/poezio/mam.py
@@ -6,13 +6,9 @@
XEP-0313: Message Archive Management(MAM).
"""
-from getpass import getpass
-from argparse import ArgumentParser
-
-import slixmpp
+import asyncio
from datetime import datetime, timezone
from poezio.theming import get_theme
-from slixmpp.exceptions import XMPPError
from poezio.text_buffer import Message, TextBuffer
@@ -38,28 +34,21 @@ def add_line(text_buffer: TextBuffer, text: str, str_time: str, nick: str):
)
-class MAM(slixmpp.ClientXMPP):
+class MAM:
"""
A basic client fetching mam archive messages
"""
def __init__(self, jid, password, remote_jid, start, end, tab):
- slixmpp.ClientXMPP.__init__(self, jid, password)
self.remote_jid = remote_jid
self.start_date = start
self.end_date = end
self.tab = tab
+ asyncio.ensure_future(self.start())
- self.add_event_handler("session_start", self.start)
-
- async def start(self, *args):
- """
- Fetches mam results for the specified JID.
- """
-
+ async def start(self):
text_buffer = self.tab._text_buffer
-
- results = self.plugin['xep_0313'].retrieve(jid=self.remote_jid,
+ results = self.tab.core.xmpp.plugin['xep_0313'].retrieve(jid=self.remote_jid,
iterator=True, start=self.start_date, end=self.end_date)
async for rsm in results:
for msg in rsm['mam']['results']:
@@ -70,4 +59,3 @@ class MAM(slixmpp.ClientXMPP):
self.tab.text_win.pos = 0
self.tab.core.refresh_window()
- self.disconnect()