🌀 尝试新增AT全体管理功能

This commit is contained in:
xtaodada 2020-04-02 20:34:19 +08:00
parent d6a20fd458
commit 75292a48c4
No known key found for this signature in database
GPG Key ID: 39EFACA711DF5D8C

View File

@ -3,7 +3,8 @@
import requests
import json
from telethon.tl.functions.messages import DeleteChatUserRequest
from telethon.tl.functions.channels import LeaveChannelRequest
from telethon.tl.functions.channels import LeaveChannelRequest,GetParticipantsRequest
from telethon.tl.types import ChannelParticipantsAdmins
from telethon.errors.rpcerrorlist import ChatIdInvalidError
from distutils2.util import strtobool
from pagermaid import bot, log, config
@ -174,6 +175,23 @@ async def hitokoto(context):
await context.edit(f"{hitokoto_json['hitokoto']} - {hitokoto_json['from']} ({str(hitokoto_type)})")
@listener(outgoing=True, command="admin",
description="@ 本群的管理员 (谨慎使用)")
async def get_admin(context):
""" It can let you at all admins. """
if context.is_group:
await context.edit("正在获取管理员列表。")
get_admin_lists = []
try:
for user in bot(GetParticipantsRequest(channel=context.chat_id, filter=ChannelParticipantsAdmins)):
get_admin_lists.extend(['[' + str(user.first_name) + '](tg://user?id=' + str(user.id) + ')'])
await context.edit(' '.join(get_admin_lists))
except:
await context.edit("出错了呜呜呜 ~")
else:
await context.edit("出错了呜呜呜 ~ 当前聊天不是群聊。")
@listener(outgoing=True, command="source",
description="显示原始 PagerMaid git 存储库的URL。")
async def source(context):