forked from kate/uniborg
Fix fixreply on different chats
This commit is contained in:
parent
59a0ebe9dc
commit
b4be66162e
|
@ -6,22 +6,22 @@ import asyncio
|
||||||
from telethon import events
|
from telethon import events
|
||||||
|
|
||||||
|
|
||||||
_last_message = None
|
_last_messages = {}
|
||||||
|
|
||||||
|
|
||||||
@borg.on(events.NewMessage(outgoing=True))
|
@borg.on(events.NewMessage(outgoing=True))
|
||||||
async def _(event):
|
async def _(event):
|
||||||
global _last_message
|
_last_messages[event.chat_id] = event.message
|
||||||
_last_message = event.message
|
|
||||||
|
|
||||||
|
|
||||||
@borg.on(events.NewMessage(pattern=r"\.(fix)?reply", outgoing=True))
|
@borg.on(events.NewMessage(pattern=r"\.(fix)?reply", outgoing=True))
|
||||||
async def _(event):
|
async def _(event):
|
||||||
if not event.is_reply or not _last_message:
|
if not event.is_reply or event.chat_id not in _last_messages:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
message = _last_messages[event.chat_id]
|
||||||
chat = await event.get_input_chat()
|
chat = await event.get_input_chat()
|
||||||
await asyncio.wait([
|
await asyncio.wait([
|
||||||
borg.delete_messages(chat, [event.id, _last_message.id]),
|
borg.delete_messages(chat, [event.id, message.id]),
|
||||||
borg.send_message(chat, _last_message, reply_to=event.reply_to_msg_id)
|
borg.send_message(chat, message, reply_to=event.reply_to_msg_id)
|
||||||
])
|
])
|
||||||
|
|
Loading…
Reference in New Issue