From 9c01f3f2cae7e8d5418bd27aa3744cab7f84df54 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Thu, 15 Jul 2021 19:02:26 +0800 Subject: [PATCH] =?UTF-8?q?forcesubscribe=20=E4=BF=AE=E5=A4=8D=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E8=AF=86=E5=88=AB=E7=94=A8=E6=88=B7=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- forcesubscribe.py | 12 ++++++++++-- list.json | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/forcesubscribe.py b/forcesubscribe.py index dee5b61..3c0ec6d 100644 --- a/forcesubscribe.py +++ b/forcesubscribe.py @@ -26,7 +26,11 @@ async def force_subscribe_join(event: ChatAction.Event): if redis.get(f"sub.chat_id.{event.chat_id}.{user.id}"): return try: - await bot(GetParticipantRequest(join_chat, user.id)) + try: + await bot(GetParticipantRequest(join_chat, user.id)) + except ValueError: + user_input = await event.get_input_user() + await bot(GetParticipantRequest(join_chat, user_input)) redis.set(f'sub.chat_id.{event.chat_id}.{user.id}', 'true') redis.expire(f'sub.chat_id.{event.chat_id}.{user.id}', 3600) except UserNotParticipantError: @@ -51,7 +55,11 @@ async def force_subscribe_msg(context: Message): if context.sender.bot: return try: - await bot(GetParticipantRequest(join_chat, context.sender_id)) + try: + await bot(GetParticipantRequest(join_chat, context.sender_id)) + except ValueError: + await bot.get_participants(context.chat) + await bot(GetParticipantRequest(join_chat, context.sender_id)) redis.set(f'sub.chat_id.{context.chat_id}.{context.sender_id}', 'true') redis.expire(f'sub.chat_id.{context.chat_id}.{context.sender_id}', 3600) except UserNotParticipantError: diff --git a/list.json b/list.json index 80aee2b..27991ba 100644 --- a/list.json +++ b/list.json @@ -612,7 +612,7 @@ }, { "name": "forcesubscribe", - "version": "1.01", + "version": "1.02", "section": "daily", "maintainer": "xtaodada", "size": "4.2 kb",