Log first, then run interactive commands

This commit is contained in:
Michael De Roover 2021-11-29 14:31:42 +01:00
parent 116a6d7deb
commit 5c5ecd7f48
Signed by: vim
GPG Key ID: 075496E232CE04CB

29
log.py
View File

@ -5,21 +5,6 @@ from config import *
client = TelegramClient('telelog', api_id, api_hash)
@client.on(events.NewMessage)
async def edit(event):
msg = event.raw_text
if event.sender_id != myid:
return
if msg.startswith('.tl.alive'):
rpl = "Telelog alive and well!"
await event.edit(rpl)
if msg.startswith('.tl.log'):
chat = str(msg.split()[1])
f = open(chat)
await event.edit(f.read())
async def log(event):
if event.is_private:
if event.sender_id != myid:
@ -42,5 +27,19 @@ async def log(event):
f.write(event.raw_text + "\n")
f.close()
# Interactive commands
msg = event.raw_text
if event.sender_id != myid:
return
if msg.startswith('.tl.alive'):
rpl = "Telelog alive and well!"
await event.edit(rpl)
if msg.startswith('.tl.log'):
chat = str(msg.split()[1])
f = open(chat)
await event.edit(f.read())
client.start()
client.run_until_disconnected()