Fix fixreply on different chats

This commit is contained in:
Lonami 2019-03-04 08:05:40 +01:00
parent 59a0ebe9dc
commit b4be66162e
1 changed files with 6 additions and 6 deletions

View File

@ -6,22 +6,22 @@ import asyncio
from telethon import events
_last_message = None
_last_messages = {}
@borg.on(events.NewMessage(outgoing=True))
async def _(event):
global _last_message
_last_message = event.message
_last_messages[event.chat_id] = event.message
@borg.on(events.NewMessage(pattern=r"\.(fix)?reply", outgoing=True))
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
message = _last_messages[event.chat_id]
chat = await event.get_input_chat()
await asyncio.wait([
borg.delete_messages(chat, [event.id, _last_message.id]),
borg.send_message(chat, _last_message, reply_to=event.reply_to_msg_id)
borg.delete_messages(chat, [event.id, message.id]),
borg.send_message(chat, message, reply_to=event.reply_to_msg_id)
])