mirror of
https://github.com/Xtao-Labs/iShotaBot.git
synced 2024-11-16 04:35:55 +00:00
✨ banme 消息 60s 后自动删除
This commit is contained in:
parent
7950b18020
commit
0137119990
@ -6,6 +6,7 @@ from pyrogram import Client, filters
|
||||
from pyrogram.enums import ChatMemberStatus
|
||||
from pyrogram.types import Message, ChatPermissions
|
||||
from init import user_me
|
||||
from scheduler import reply_message
|
||||
|
||||
|
||||
@Client.on_message(
|
||||
@ -20,6 +21,8 @@ async def ban_me_command(client: Client, message: Message):
|
||||
multiple = int(multiple_text.groups()[0])
|
||||
else:
|
||||
multiple = 1
|
||||
if multiple > 5 or multiple < 1:
|
||||
multiple = 1
|
||||
|
||||
# 检查bot和用户身份
|
||||
if (
|
||||
@ -29,14 +32,14 @@ async def ban_me_command(client: Client, message: Message):
|
||||
return
|
||||
if not message.from_user:
|
||||
# 频道
|
||||
await message.reply("你是个频道, 别来凑热闹OvO")
|
||||
await reply_message(message, "你是个频道, 别来凑热闹OvO")
|
||||
return
|
||||
|
||||
member = (
|
||||
await client.get_chat_member(message.chat.id, message.from_user.id)
|
||||
).status
|
||||
if member in [ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
|
||||
await message.reply("你也是个管理, 别来凑热闹OvO")
|
||||
await reply_message(message, "你也是个管理, 别来凑热闹OvO")
|
||||
return
|
||||
|
||||
# 随机禁言时间
|
||||
@ -50,4 +53,4 @@ async def ban_me_command(client: Client, message: Message):
|
||||
ChatPermissions(),
|
||||
datetime.now() + timedelta(seconds=act_time),
|
||||
)
|
||||
await message.reply(msg)
|
||||
await reply_message(message, msg)
|
||||
|
@ -26,3 +26,10 @@ def add_delete_message_job(message: Message, delete_seconds: int = 60):
|
||||
+ datetime.timedelta(seconds=delete_seconds),
|
||||
replace_existing=True,
|
||||
)
|
||||
|
||||
|
||||
async def reply_message(msg: Message, text: str, delete_origin: bool = True, *args, **kwargs):
|
||||
reply_msg = await msg.reply(text, *args, **kwargs)
|
||||
add_delete_message_job(reply_msg)
|
||||
if delete_origin:
|
||||
add_delete_message_job(msg)
|
||||
|
Loading…
Reference in New Issue
Block a user