listusernames 列出所有属于自己的公开群组/频道

This commit is contained in:
xtaodada 2022-07-24 17:39:01 +08:00
parent 5b1449fd10
commit 2746fedf49
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 29 additions and 0 deletions

View File

@ -469,6 +469,16 @@
"supported": true, "supported": true,
"des-short": "Play a game of 1A2B", "des-short": "Play a game of 1A2B",
"des": "Play a game of 1A2B, command:,1a2b" "des": "Play a game of 1A2B, command:,1a2b"
},
{
"name": "listusernames",
"version": "1.0",
"section": "daily",
"maintainer": "xtaodada",
"size": "0.7 kb",
"supported": true,
"des-short": "列出所有属于自己的公开群组/频道。",
"des": "列出所有属于自己的公开群组/频道。命令:,listusernames"
} }
] ]
} }

19
listusernames/main.py Normal file
View File

@ -0,0 +1,19 @@
from pagermaid.enums import Client, Message
from pagermaid.listener import listener
from pyrogram.raw.functions.channels import GetAdminedPublicChannels
@listener(command="listusernames",
admins_only=True,
description="列出所有属于自己的公开群组/频道。")
async def list_usernames(bot: Client, message: Message):
""" Get a list of your reserved usernames. """
result = await bot.invoke(GetAdminedPublicChannels())
output = f"以下是属于我的 {len(result.chats)} 个所有公开群组/频道:\n\n"
for i in result.chats:
try:
output += f"{i.title}\n@{i.username}\n\n"
except AttributeError:
output += f"{i.title}\n\n"
await message.edit(output)