forcesubscribe 修复无法识别用户的问题

This commit is contained in:
xtaodada 2021-07-15 19:02:26 +08:00
parent e932e9e711
commit 9c01f3f2ca
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736
2 changed files with 11 additions and 3 deletions

View File

@ -26,7 +26,11 @@ async def force_subscribe_join(event: ChatAction.Event):
if redis.get(f"sub.chat_id.{event.chat_id}.{user.id}"): if redis.get(f"sub.chat_id.{event.chat_id}.{user.id}"):
return return
try: 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.set(f'sub.chat_id.{event.chat_id}.{user.id}', 'true')
redis.expire(f'sub.chat_id.{event.chat_id}.{user.id}', 3600) redis.expire(f'sub.chat_id.{event.chat_id}.{user.id}', 3600)
except UserNotParticipantError: except UserNotParticipantError:
@ -51,7 +55,11 @@ async def force_subscribe_msg(context: Message):
if context.sender.bot: if context.sender.bot:
return return
try: 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.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) redis.expire(f'sub.chat_id.{context.chat_id}.{context.sender_id}', 3600)
except UserNotParticipantError: except UserNotParticipantError:

View File

@ -612,7 +612,7 @@
}, },
{ {
"name": "forcesubscribe", "name": "forcesubscribe",
"version": "1.01", "version": "1.02",
"section": "daily", "section": "daily",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "4.2 kb", "size": "4.2 kb",