feat: do not verify admin invite

This commit is contained in:
xtaodada 2023-05-12 22:09:43 +08:00
parent 262a93dd6f
commit 0ee2aabaaa
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
3 changed files with 16 additions and 4 deletions

View File

@ -36,6 +36,7 @@ async def new_member(client: Client, chat_join_request: ChatJoinRequest):
except TimeoutConversationError: except TimeoutConversationError:
with contextlib.suppress(Exception): with contextlib.suppress(Exception):
await client.send_message(user.id, MSG_FAILURE) 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): with contextlib.suppress(Exception):
await log(chat, user, "FAIL_TIMEOUT") await log(chat, user, "FAIL_TIMEOUT")

View File

@ -2,9 +2,10 @@ import contextlib
from datetime import datetime, timedelta from datetime import datetime, timedelta
from pyrogram.enums import MessageServiceType from pyrogram.enums import MessageServiceType, ChatMemberStatus
from pyrogram import filters from pyrogram import filters
from sticker.scheduler import add_delete_message_job
from sticker.single_utils import Client, Message from sticker.single_utils import Client, Message
from sticker import bot, log from sticker import bot, log
@ -13,6 +14,7 @@ from pyromod.utils.errors import TimeoutConversationError
MSG = """您好 %s ,当前群组开启了验证功能。 MSG = """您好 %s ,当前群组开启了验证功能。
您需要在 30 秒内发送任意一个 贴纸 来完成验证""" 您需要在 30 秒内发送任意一个 贴纸 来完成验证"""
ADMIN_MSG = """管理员邀请,自动放行。"""
@bot.on_message(filters.service) @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 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: if user.is_self or user.is_verified or user.is_bot or user.is_deleted or user.is_support:
return 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: try:
msg = await message.reply(MSG % user.mention) msg = await message.reply(MSG % user.mention)
except Exception as e: except Exception:
return return
try: try:
with contextlib.suppress(Exception): with contextlib.suppress(Exception):

View File

@ -1,4 +1,4 @@
pyrogram==2.0.30 pyrogram==2.0.106
TgCrypto>=1.2.3 TgCrypto>=1.2.3
PyYAML>=6.0 PyYAML>=6.0
coloredlogs>=15.0.1 coloredlogs>=15.0.1