mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-22 07:08:18 +00:00
forcesubscribe 消息发送 5 秒后自动删除
This commit is contained in:
parent
f233dbdd8b
commit
e932e9e711
@ -1,6 +1,7 @@
|
||||
from pagermaid import bot, redis, redis_status
|
||||
from pagermaid.utils import lang, alias_command
|
||||
from pagermaid.listener import listener
|
||||
from asyncio import sleep
|
||||
from telethon.events.chataction import ChatAction
|
||||
from telethon.tl.custom.message import Message
|
||||
from telethon.tl.functions.channels import GetParticipantRequest
|
||||
@ -29,7 +30,9 @@ async def force_subscribe_join(event: ChatAction.Event):
|
||||
redis.set(f'sub.chat_id.{event.chat_id}.{user.id}', 'true')
|
||||
redis.expire(f'sub.chat_id.{event.chat_id}.{user.id}', 3600)
|
||||
except UserNotParticipantError:
|
||||
await event.reply(f'[{user.first_name}](tg://user?id={user.id}) 您需要先加入频道 @{join_chat} 才能发言。')
|
||||
msg = await event.reply(f'[{user.first_name}](tg://user?id={user.id}) 您需要先加入频道 @{join_chat} 才能发言。')
|
||||
await sleep(5)
|
||||
await msg.delete()
|
||||
except ChatAdminRequiredError:
|
||||
redis.delete(f"sub.chat_id.{event.chat_id}")
|
||||
|
||||
@ -54,9 +57,11 @@ async def force_subscribe_msg(context: Message):
|
||||
except UserNotParticipantError:
|
||||
try:
|
||||
await context.delete()
|
||||
await bot.send_message(context.chat_id,
|
||||
f'[{context.sender.first_name}](tg://user?id={context.sender_id}) '
|
||||
f'您需要先加入频道 @{join_chat} 才能发言。')
|
||||
msg = await bot.send_message(context.chat_id,
|
||||
f'[{context.sender.first_name}](tg://user?id={context.sender_id}) '
|
||||
f'您需要先加入频道 @{join_chat} 才能发言。')
|
||||
await sleep(5)
|
||||
await msg.delete()
|
||||
except ChatAdminRequiredError:
|
||||
redis.delete(f"sub.chat_id.{context.chat_id}")
|
||||
except ChatAdminRequiredError:
|
||||
|
Loading…
Reference in New Issue
Block a user