From 75292a48c46c3c03a9e310bfe0013bd6bed302a4 Mon Sep 17 00:00:00 2001 From: xtaodada <1344089750@qq.com> Date: Thu, 2 Apr 2020 20:34:19 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=80=20=E5=B0=9D=E8=AF=95=E6=96=B0?= =?UTF-8?q?=E5=A2=9EAT=E5=85=A8=E4=BD=93=E7=AE=A1=E7=90=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pagermaid/modules/message.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pagermaid/modules/message.py b/pagermaid/modules/message.py index 5dda12a..cf36a59 100644 --- a/pagermaid/modules/message.py +++ b/pagermaid/modules/message.py @@ -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):