mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 10:53:44 +03:00
Fix message deletion, replies and chat IDs on the GUI
This commit is contained in:
parent
da5914c4a0
commit
a495f542ef
|
@ -15,8 +15,8 @@ from telethon import TelegramClient, events, utils
|
||||||
# Some configuration for the app
|
# Some configuration for the app
|
||||||
TITLE = 'Telethon GUI'
|
TITLE = 'Telethon GUI'
|
||||||
SIZE = '640x280'
|
SIZE = '640x280'
|
||||||
REPLY = re.compile(r'\.r(\d+)\s*(.+)', re.IGNORECASE)
|
REPLY = re.compile(r'\.r\s*(\d+)\s*(.+)', re.IGNORECASE)
|
||||||
DELETE = re.compile(r'\.d(\d+)', re.IGNORECASE)
|
DELETE = re.compile(r'\.d\s*(\d+)', re.IGNORECASE)
|
||||||
EDIT = re.compile(r'\.s(.+?[^\\])/(.*)', re.IGNORECASE)
|
EDIT = re.compile(r'\.s(.+?[^\\])/(.*)', re.IGNORECASE)
|
||||||
|
|
||||||
# Session name, API ID and hash to use; loaded from environmental variables
|
# Session name, API ID and hash to use; loaded from environmental variables
|
||||||
|
@ -101,6 +101,7 @@ class App(tkinter.Tk):
|
||||||
|
|
||||||
# Save shown message IDs to support replying with ".rN reply"
|
# Save shown message IDs to support replying with ".rN reply"
|
||||||
# For instance to reply to the last message ".r1 this is a reply"
|
# For instance to reply to the last message ".r1 this is a reply"
|
||||||
|
# Deletion also works with ".dN".
|
||||||
self.message_ids = []
|
self.message_ids = []
|
||||||
|
|
||||||
# Save the sent texts to allow editing with ".s text/replacement"
|
# Save the sent texts to allow editing with ".s text/replacement"
|
||||||
|
@ -253,7 +254,7 @@ class App(tkinter.Tk):
|
||||||
m = DELETE.match(text)
|
m = DELETE.match(text)
|
||||||
if m:
|
if m:
|
||||||
try:
|
try:
|
||||||
delete = self.message_ids[-int(m.group(1))]
|
delete = self.message_ids.pop(-int(m.group(1)))
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -291,8 +292,10 @@ class App(tkinter.Tk):
|
||||||
Checks the input chat where to send and listen messages from.
|
Checks the input chat where to send and listen messages from.
|
||||||
"""
|
"""
|
||||||
chat = self.chat.get().strip()
|
chat = self.chat.get().strip()
|
||||||
if chat.isdigit():
|
try:
|
||||||
chat = int(chat)
|
chat = int(chat)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
old = self.chat_id
|
old = self.chat_id
|
||||||
|
|
Loading…
Reference in New Issue
Block a user