From 177823f46ed0e495309ae7914dee13996f38c34b Mon Sep 17 00:00:00 2001 From: Xtao_dada Date: Mon, 16 Aug 2021 22:34:37 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20some=20bugs=20(mock,re,sel?= =?UTF-8?q?fprune)=20(#116)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🐛 修复 mock, re, selfprune 运行错误。 --- pagermaid/modules/fun.py | 17 ++++++++++------- pagermaid/modules/message.py | 5 ++++- pagermaid/modules/prune.py | 5 ++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/pagermaid/modules/fun.py b/pagermaid/modules/fun.py index a4a268e..4bd73c5 100644 --- a/pagermaid/modules/fun.py +++ b/pagermaid/modules/fun.py @@ -74,13 +74,16 @@ async def mock(context): reply = await context.get_reply_message() await context.edit(result) if reply: - if reply.sender.is_self: - try: - await reply.edit(result) - except MessageNotModifiedError: - await context.edit("A rare event of two mocking messages being the same just occurred.") - return - await context.delete() + try: + if reply.sender.is_self: + try: + await reply.edit(result) + except MessageNotModifiedError: + await context.edit("A rare event of two mocking messages being the same just occurred.") + return + await context.delete() + except AttributeError: + pass @listener(is_plugin=False, outgoing=True, command=alias_command("widen"), diff --git a/pagermaid/modules/message.py b/pagermaid/modules/message.py index 7d4cc35..226d73d 100644 --- a/pagermaid/modules/message.py +++ b/pagermaid/modules/message.py @@ -147,7 +147,10 @@ async def re(context): except: await context.edit(lang('re_arg_error')) return True - await context.delete() + try: + await context.delete() + except ValueError: + pass try: for nums in range(0, num): await reply.forward_to(int(context.chat_id)) diff --git a/pagermaid/modules/prune.py b/pagermaid/modules/prune.py index 19ee0e5..b8ec211 100644 --- a/pagermaid/modules/prune.py +++ b/pagermaid/modules/prune.py @@ -81,7 +81,10 @@ async def selfprune(context): if msgs: await context.client.delete_messages(context.chat_id, msgs) await log(f"{lang('prune_hint1')}{lang('sp_hint')} {str(count_buffer)} / {str(count)} {lang('prune_hint2')}") - notification = await send_prune_notify(context, count_buffer, count) + try: + notification = await send_prune_notify(context, count_buffer, count) + except ValueError: + pass await sleep(1) await notification.delete()