From 7569dc8aa6e9b9280b128c9f7aa3208239e34c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Thu, 11 Mar 2021 16:57:06 +0100 Subject: show client history --- TODO | 4 +--- cursed.py | 5 ++++- main.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index a815c76..98b77e4 100644 --- a/TODO +++ b/TODO @@ -8,15 +8,13 @@ daily driver: - commands - tg chat - tg list -- show chat history - notifications - libnotify - silent messages - shift + enter to insert new line -- show sent/received -- show sending status (sending, sent, read) by updating icon later: +- show sending status (sending, sent, read) by updating icon - show someone is typing - support groupchats - configuration framework diff --git a/cursed.py b/cursed.py index a4c71bb..e5c17ee 100644 --- a/cursed.py +++ b/cursed.py @@ -29,7 +29,10 @@ class Console(): self.stdscr.addstr(self.typed_message) self.stdscr.refresh() - async def start(self, on_str, on_tab): + async def start(self, client, on_str, on_tab): + async for message in client.iter_messages("+46763060644", limit=10): + self.messages.insert(0, Message(message.raw_text, message.id, " ")) + while True: self.redraw() char = await asyncio.to_thread(self.stdscr.get_wch) diff --git a/main.py b/main.py index eb2b3b2..3ddbde2 100644 --- a/main.py +++ b/main.py @@ -17,7 +17,7 @@ def main(): tele.redraw = lambda: c.redraw() with tele.client: tele.client.start() - tele.client.loop.run_until_complete(c.start(on_str, on_tab)) + tele.client.loop.run_until_complete(c.start(tele.client, on_str, on_tab)) if __name__=="__main__": -- cgit v1.2.1