From b4be66162e69ad5608c21996b5ae00875bd24790 Mon Sep 17 00:00:00 2001 From: Lonami Date: Mon, 4 Mar 2019 08:05:40 +0100 Subject: [PATCH] Fix fixreply on different chats --- stdplugins/fixreply.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stdplugins/fixreply.py b/stdplugins/fixreply.py index fded163..997ad6e 100644 --- a/stdplugins/fixreply.py +++ b/stdplugins/fixreply.py @@ -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) ])