Better chat history for the GUI

This commit is contained in:
Lonami Exo 2018-08-28 16:37:55 +02:00
parent 40650f93ce
commit 3a0b091210

View File

@ -73,6 +73,8 @@ class App(tkinter.Tk):
def __init__(self, client, *args, **kwargs):
super().__init__(*args, **kwargs)
self.cl = client
self.me = None
self.title(TITLE)
self.geometry(SIZE)
@ -203,6 +205,7 @@ class App(tkinter.Tk):
Configures the application as "signed in" (displays user's
name and disables the entry to input phone/bot token/code).
"""
self.me = me
self.sign_in_label.configure(text='Signed in')
self.sign_in_entry.configure(state=tkinter.NORMAL)
self.sign_in_entry.delete(0, tkinter.END)
@ -299,6 +302,9 @@ class App(tkinter.Tk):
"""
Checks the input chat where to send and listen messages from.
"""
if self.me is None:
return # Not logged in yet
chat = self.chat.get().strip()
try:
chat = int(chat)
@ -316,6 +322,8 @@ class App(tkinter.Tk):
if self.chat_id != old:
self.message_ids.clear()
self.sent_text.clear()
self.log.delete('1.0', tkinter.END)
if not self.me.bot:
for msg in reversed(
await self.cl.get_messages(self.chat_id, 100)):
await self.on_message(msg)