mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-22 05:09:15 +00:00
🚩 nthmsg portball
This commit is contained in:
parent
e747380f02
commit
67770c945e
@ -54,6 +54,8 @@
|
||||
- `sendat` : 定时发送消息。
|
||||
- `atadmins_atall` : 一键 AT 本群管理员、群员。
|
||||
- `denyu` : 在某群中强制禁言某用户。
|
||||
- `nthmsg` : 获取你发送的第 n 条消息。
|
||||
- `portball` : 回复你要临时禁言的人的消息来实现XX秒的禁言。
|
||||
- profile (资料类)
|
||||
- `autochangename` : 自动更新 last_name 为时间等。
|
||||
- `throwit` : 生成一张 扔头像 图片。
|
||||
|
20
list.json
20
list.json
@ -139,6 +139,26 @@
|
||||
"supported": true,
|
||||
"des-short": "生成隐藏链接。",
|
||||
"des": "非链接的纯文字将直接隐藏。"
|
||||
},
|
||||
{
|
||||
"name": "nthmsg",
|
||||
"version": "1.0",
|
||||
"section": "chat",
|
||||
"maintainer": "seiuneko",
|
||||
"size": "0.9 kb",
|
||||
"supported": true,
|
||||
"des-short": "获取你发送的第 n 条消息。",
|
||||
"des": "这个人很懒,什么都没有留下。"
|
||||
},
|
||||
{
|
||||
"name": "portball",
|
||||
"version": "1.0",
|
||||
"section": "chat",
|
||||
"maintainer": "丢失了",
|
||||
"size": "3.0 kb",
|
||||
"supported": false,
|
||||
"des-short": "回复你要临时禁言的人的消息来实现XX秒的禁言。",
|
||||
"des": "这个人很懒,什么都没有留下。"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
28
nthmsg.py
Normal file
28
nthmsg.py
Normal file
@ -0,0 +1,28 @@
|
||||
from pagermaid.listener import listener
|
||||
# from pagermaid import log
|
||||
from telethon import functions, types
|
||||
|
||||
|
||||
@listener(outgoing=True,
|
||||
command="nthmsg",
|
||||
description="获取你发送的第 n 条消息,默认为第一条",
|
||||
parameters="<n>")
|
||||
async def nthmsg(context):
|
||||
await context.edit("获取中 . . .")
|
||||
|
||||
try:
|
||||
n = int(context.parameter[0])
|
||||
except:
|
||||
n = 1
|
||||
|
||||
m = object()
|
||||
async for m in context.client.iter_messages(context.chat_id,
|
||||
from_user="me",
|
||||
reverse=True,
|
||||
limit=n):
|
||||
pass
|
||||
r = await context.client(
|
||||
functions.channels.ExportMessageLinkRequest(channel=m.to_id,
|
||||
id=m.id,
|
||||
grouped=True))
|
||||
await context.edit(r.link)
|
63
portball.py
Normal file
63
portball.py
Normal file
@ -0,0 +1,63 @@
|
||||
from pagermaid import bot, log
|
||||
from pagermaid.listener import listener
|
||||
from telethon.errors import rpcerrorlist
|
||||
from asyncio import sleep
|
||||
from datetime import timedelta
|
||||
from telethon.tl.types import ChannelParticipantsAdmins
|
||||
|
||||
|
||||
@listener(incoming=True, outgoing=True, command="portball",
|
||||
description="回复你要临时禁言的人的消息来实现XX秒的禁言。",
|
||||
parameters="<理由> <时间 单位:秒>")
|
||||
async def portball(context):
|
||||
reply = await context.get_reply_message()
|
||||
if context.is_group:
|
||||
if reply:
|
||||
action = context.arguments.split()
|
||||
if reply.sender.last_name == None:
|
||||
last_name = ''
|
||||
else:
|
||||
last_name = reply.sender.last_name
|
||||
if int(action[1])<60:
|
||||
notification = await bot.send_message(context.chat_id, '诶呀不要小于60秒啦')
|
||||
await sleep(10)
|
||||
await notification.delete()
|
||||
try:
|
||||
await context.delete()
|
||||
except:
|
||||
pass
|
||||
return False
|
||||
admins = await context.client.get_participants(context.chat, filter=ChannelParticipantsAdmins)
|
||||
if context.sender in admins:
|
||||
try:
|
||||
await bot.edit_permissions(context.chat_id, reply.sender.id, timedelta(seconds=int(action[1].replace(' ',''))), send_messages=False)
|
||||
await bot.send_message(
|
||||
context.chat_id,
|
||||
f'[{reply.sender.first_name}{last_name}](tg://user?id={reply.sender.id}) 由于 {action[0]} \n'
|
||||
f'被暂时禁言{action[1]}秒',
|
||||
reply_to = reply.id
|
||||
)
|
||||
except rpcerrorlist.UserAdminInvalidError:
|
||||
notification = await bot.send_message(context.chat_id, '错误:我没有管理员权限或我的权限比被封禁的人要小')
|
||||
await sleep(10)
|
||||
await notification.delete()
|
||||
except rpcerrorlist.ChatAdminRequiredError:
|
||||
notification = await bot.send_message(context.chat_id, '错误:我没有管理员权限或我的权限比被封禁的人要小')
|
||||
await sleep(10)
|
||||
await notification.delete()
|
||||
else:
|
||||
notification = await bot.send_message(context.chat_id, '诶呀你不是管理员,不要给人家塞口球啊')
|
||||
await sleep(10)
|
||||
await notification.delete()
|
||||
else:
|
||||
notification = await bot.send_message(context.chat_id, '你好蠢诶,都没有回复人,我哪知道你要搞谁的事情……')
|
||||
await sleep(10)
|
||||
await notification.delete()
|
||||
else:
|
||||
notification = await bot.send_message(context.chat_id, '你好蠢诶,又不是群组,怎么禁言啦!')
|
||||
await sleep(10)
|
||||
await notification.delete()
|
||||
try:
|
||||
await context.delete()
|
||||
except:
|
||||
pass
|
Loading…
Reference in New Issue
Block a user