From 0f256f9bb32360720033d44f60863ea7fd92c601 Mon Sep 17 00:00:00 2001 From: code-rgb <62891774+code-rgb@users.noreply.github.com> Date: Sat, 24 Oct 2020 14:00:42 +0530 Subject: [PATCH 1/4] Update admins.py --- userge/plugins/utils/admins.py | 36 +++++++++++++++------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/userge/plugins/utils/admins.py b/userge/plugins/utils/admins.py index 9fab430bb..bc6992c9b 100644 --- a/userge/plugins/utils/admins.py +++ b/userge/plugins/utils/admins.py @@ -1,13 +1,6 @@ -# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >. -# -# This file is part of < https://github.com/UsergeTeam/Userge > project, -# and is released under the "GNU v3.0 License Agreement". -# Please see < https://github.com/uaudith/Userge/blob/master/LICENSE > -# -# All rights reserved. from userge import Message, userge - +from userge.utils import mention_html @userge.on_cmd( "admins", @@ -23,7 +16,8 @@ allow_channels=False, ) async def mentionadmins(message: Message): - mentions = "🛡 **Admin List** 🛡\n" + owner_ = "" + admins_ = "" chat_id = message.filtered_input_str flags = message.flags men_admins = "-m" in flags @@ -31,6 +25,7 @@ async def mentionadmins(message: Message): show_id = "-id" in flags if not chat_id: chat_id = message.chat.id + mentions = "Admins in {}\n\n".format((await message.client.get_chat(chat_id)).title) try: async for x in message.client.iter_chat_members( chat_id=chat_id, filter="administrators" @@ -41,25 +36,26 @@ async def mentionadmins(message: Message): full_name = (await message.client.get_user_dict(u_id))["flname"] if status == "creator": if men_admins or men_creator: - mentions += f"\n 👑 [{full_name}](tg://user?id={u_id})" + owner_ += f"\n 👑 {mention_html(u_id, full_name)}" elif username: - mentions += f"\n 👑 [{full_name}](https://t.me/{username})" + owner_ += f"\n 👑 [{full_name}](https://t.me/{username})" else: - mentions += f"\n 👑 {full_name}" + owner_ += f"\n 👑 [{full_name}](tg://openmessage?user_id={u_id})" if show_id: - mentions += f" `{u_id}`" + owner_ += f"👑 `{u_id}`" elif status == "administrator": if men_admins: - mentions += f"\n >> [{full_name}](tg://user?id={u_id})" + admins_ += f"\n • {mention_html(u_id, full_name)}" elif username: - mentions += f"\n >> [{full_name}](https://t.me/{username})" + admins_ += f"\n • [{full_name}](https://t.me/{username})" else: - mentions += f"\n >> {full_name}" + admins_ += f"\n • [{full_name}](tg://openmessage?user_id={u_id})" if show_id: - mentions += f" `{u_id}`" + admins_ += f"• `{u_id}`" + + mentions += f"{owner_}\n{admins_}" except Exception as e: mentions += " " + str(e) + "\n" - await message.delete() - await message.client.send_message( - chat_id=message.chat.id, text=mentions, disable_web_page_preview=True + await message.edit( + mentions, disable_web_page_preview=True ) From f1c039fdf6ea650a1f6cc9663dc1a3270d27ca31 Mon Sep 17 00:00:00 2001 From: code-rgb <62891774+code-rgb@users.noreply.github.com> Date: Sat, 24 Oct 2020 08:31:25 +0000 Subject: [PATCH 2/4] pylint: auto fixes --- userge/plugins/utils/admins.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/userge/plugins/utils/admins.py b/userge/plugins/utils/admins.py index bc6992c9b..b47ee62e8 100644 --- a/userge/plugins/utils/admins.py +++ b/userge/plugins/utils/admins.py @@ -1,7 +1,7 @@ - from userge import Message, userge from userge.utils import mention_html + @userge.on_cmd( "admins", about={ @@ -25,7 +25,9 @@ async def mentionadmins(message: Message): show_id = "-id" in flags if not chat_id: chat_id = message.chat.id - mentions = "Admins in {}\n\n".format((await message.client.get_chat(chat_id)).title) + mentions = "Admins in {}\n\n".format( + (await message.client.get_chat(chat_id)).title + ) try: async for x in message.client.iter_chat_members( chat_id=chat_id, filter="administrators" @@ -56,6 +58,4 @@ async def mentionadmins(message: Message): mentions += f"{owner_}\n{admins_}" except Exception as e: mentions += " " + str(e) + "\n" - await message.edit( - mentions, disable_web_page_preview=True - ) + await message.edit(mentions, disable_web_page_preview=True) From 34f759348d80a44a4ca4b4ec355e421d3d9db278 Mon Sep 17 00:00:00 2001 From: code-rgb <62891774+code-rgb@users.noreply.github.com> Date: Sat, 24 Oct 2020 15:52:48 +0530 Subject: [PATCH 3/4] Update admins.py --- userge/plugins/utils/admins.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/userge/plugins/utils/admins.py b/userge/plugins/utils/admins.py index bc6992c9b..9ff97114f 100644 --- a/userge/plugins/utils/admins.py +++ b/userge/plugins/utils/admins.py @@ -18,6 +18,7 @@ async def mentionadmins(message: Message): owner_ = "" admins_ = "" + bots_ = "" chat_id = message.filtered_input_str flags = message.flags men_admins = "-m" in flags @@ -25,7 +26,7 @@ async def mentionadmins(message: Message): show_id = "-id" in flags if not chat_id: chat_id = message.chat.id - mentions = "Admins in {}\n\n".format((await message.client.get_chat(chat_id)).title) + mentions = "Admins in {}\n".format((await message.client.get_chat(chat_id)).title) try: async for x in message.client.iter_chat_members( chat_id=chat_id, filter="administrators" @@ -33,6 +34,7 @@ async def mentionadmins(message: Message): status = x.status u_id = x.user.id username = x.user.username or None + is_bot = x.user.is_bot full_name = (await message.client.get_user_dict(u_id))["flname"] if status == "creator": if men_admins or men_creator: @@ -42,18 +44,23 @@ async def mentionadmins(message: Message): else: owner_ += f"\n 👑 [{full_name}](tg://openmessage?user_id={u_id})" if show_id: - owner_ += f"👑 `{u_id}`" + owner_ += f" `{u_id}`" elif status == "administrator": - if men_admins: - admins_ += f"\n • {mention_html(u_id, full_name)}" - elif username: - admins_ += f"\n • [{full_name}](https://t.me/{username})" + if is_bot: + bots_ += f"\n 🤖 {mention_html(u_id, full_name)}" + if show_id: + bots_ += f" `{u_id}`" else: - admins_ += f"\n • [{full_name}](tg://openmessage?user_id={u_id})" - if show_id: - admins_ += f"• `{u_id}`" + if men_admins: + admins_ += f"\n • {mention_html(u_id, full_name)}" + elif username: + admins_ += f"\n • [{full_name}](https://t.me/{username})" + else: + admins_ += f"\n • [{full_name}](tg://openmessage?user_id={u_id})" + if show_id: + admins_ += f" `{u_id}`" - mentions += f"{owner_}\n{admins_}" + mentions += f"{owner_}\n{admins_}{bots_}" except Exception as e: mentions += " " + str(e) + "\n" await message.edit( From 95c57d479468be0a5b434e66d2e159571d310772 Mon Sep 17 00:00:00 2001 From: code-rgb <62891774+code-rgb@users.noreply.github.com> Date: Sat, 24 Oct 2020 10:25:00 +0000 Subject: [PATCH 4/4] pylint: auto fixes --- userge/plugins/utils/admins.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/userge/plugins/utils/admins.py b/userge/plugins/utils/admins.py index dd593ea69..2f1f14f7c 100644 --- a/userge/plugins/utils/admins.py +++ b/userge/plugins/utils/admins.py @@ -58,7 +58,9 @@ async def mentionadmins(message: Message): elif username: admins_ += f"\n • [{full_name}](https://t.me/{username})" else: - admins_ += f"\n • [{full_name}](tg://openmessage?user_id={u_id})" + admins_ += ( + f"\n • [{full_name}](tg://openmessage?user_id={u_id})" + ) if show_id: admins_ += f" `{u_id}`"