From 0ee2aabaaa0cc6d87d6fdb3dbb98341c130fe196 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Fri, 12 May 2023 22:09:43 +0800 Subject: [PATCH] feat: do not verify admin invite --- plugins/new_member.py | 3 ++- plugins/service.py | 15 +++++++++++++-- requirements.txt | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/new_member.py b/plugins/new_member.py index c795952..f9533a7 100644 --- a/plugins/new_member.py +++ b/plugins/new_member.py @@ -36,6 +36,7 @@ async def new_member(client: Client, chat_join_request: ChatJoinRequest): except TimeoutConversationError: with contextlib.suppress(Exception): await client.send_message(user.id, MSG_FAILURE) - await chat_join_request.decline() + with contextlib.suppress(Exception): + await chat_join_request.decline() with contextlib.suppress(Exception): await log(chat, user, "FAIL_TIMEOUT") diff --git a/plugins/service.py b/plugins/service.py index 998eec6..b06cce1 100644 --- a/plugins/service.py +++ b/plugins/service.py @@ -2,9 +2,10 @@ import contextlib from datetime import datetime, timedelta -from pyrogram.enums import MessageServiceType +from pyrogram.enums import MessageServiceType, ChatMemberStatus from pyrogram import filters +from sticker.scheduler import add_delete_message_job from sticker.single_utils import Client, Message from sticker import bot, log @@ -13,6 +14,7 @@ from pyromod.utils.errors import TimeoutConversationError MSG = """您好 %s ,当前群组开启了验证功能。 您需要在 30 秒内发送任意一个 贴纸 来完成验证。""" +ADMIN_MSG = """管理员邀请,自动放行。""" @bot.on_message(filters.service) @@ -27,9 +29,18 @@ async def chat_members_handle(client: Client, message: Message): user = message.new_chat_members[0] if message.new_chat_members else message.from_user if user.is_self or user.is_verified or user.is_bot or user.is_deleted or user.is_support: return + if message.new_chat_members and message.from_user and ( + await bot.get_chat_member(chat.id, message.from_user.id) + ).status in {ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER}: + try: + msg = await message.reply(ADMIN_MSG) + except Exception: + return + add_delete_message_job(msg) + return try: msg = await message.reply(MSG % user.mention) - except Exception as e: + except Exception: return try: with contextlib.suppress(Exception): diff --git a/requirements.txt b/requirements.txt index df1c116..616106e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -pyrogram==2.0.30 +pyrogram==2.0.106 TgCrypto>=1.2.3 PyYAML>=6.0 coloredlogs>=15.0.1