fix: a bug

This commit is contained in:
xtaodada 2022-07-05 18:50:39 +08:00
parent 696ae2a329
commit 0ec2d8b092
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

View File

@ -6,6 +6,7 @@ from pyrogram.enums import ChatMemberStatus
from datetime import datetime, timedelta from datetime import datetime, timedelta
from pyromod.utils.errors import TimeoutConversationError from pyromod.utils.errors import TimeoutConversationError
from sticker.scheduler import add_delete_message_job
from sticker.single_utils import Message, Client from sticker.single_utils import Message, Client
from sticker import bot, log from sticker import bot, log
@ -17,6 +18,8 @@ MSG = """您好 %s ,您被管理员要求重新验证。
@bot.on_message(filters=filters.group & filters.command("reverify")) @bot.on_message(filters=filters.group & filters.command("reverify"))
async def re_verify(client: Client, message: Message): async def re_verify(client: Client, message: Message):
if not message.from_user or not message.reply_to_message: if not message.from_user or not message.reply_to_message:
msg: Message = await message.reply("请回复一条消息来使 Ta 重新验证。")
add_delete_message_job(msg, 10)
return return
if not message.reply_to_message.from_user: if not message.reply_to_message.from_user:
return return
@ -29,6 +32,7 @@ async def re_verify(client: Client, message: Message):
user = message.reply_to_message.from_user user = message.reply_to_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
member = await client.get_chat_member(chat.id, user.id)
with contextlib.suppress(Exception): with contextlib.suppress(Exception):
await message.delete() await message.delete()
try: try:
@ -42,8 +46,9 @@ async def re_verify(client: Client, message: Message):
if not msg_.sticker: if not msg_.sticker:
with contextlib.suppress(Exception): with contextlib.suppress(Exception):
await message.reply_to_message.delete() await message.reply_to_message.delete()
with contextlib.suppress(Exception): if member.status not in [ChatMemberStatus.OWNER, ChatMemberStatus.ADMINISTRATOR]:
await bot.ban_chat_member(chat.id, user.id, datetime.now() + timedelta(minutes=5)) with contextlib.suppress(Exception):
await bot.ban_chat_member(chat.id, user.id, datetime.now() + timedelta(minutes=5))
with contextlib.suppress(Exception): with contextlib.suppress(Exception):
await log(chat, user, "FAIL_ERROR") await log(chat, user, "FAIL_ERROR")
else: else:
@ -56,8 +61,8 @@ async def re_verify(client: Client, message: Message):
await msg.delete() await msg.delete()
with contextlib.suppress(Exception): with contextlib.suppress(Exception):
await message.reply_to_message.delete() await message.reply_to_message.delete()
with contextlib.suppress(Exception): if member.status not in [ChatMemberStatus.OWNER, ChatMemberStatus.ADMINISTRATOR]:
await bot.ban_chat_member(chat.id, user.id, datetime.now() + timedelta(minutes=5)) with contextlib.suppress(Exception):
await bot.ban_chat_member(chat.id, user.id, datetime.now() + timedelta(minutes=5))
with contextlib.suppress(Exception): with contextlib.suppress(Exception):
await log(chat, user, "FAIL_TIMEOUT") await log(chat, user, "FAIL_TIMEOUT")