Spaces:
Runtime error
Runtime error
| import random | |
| from pyrogram import Client | |
| from pyrogram.enums import ChatMembersFilter, ChatMemberStatus | |
| from pyrogram.types import Message | |
| from Hellbot.functions.media import get_media_fileid | |
| from Hellbot.functions.templates import chat_info_templates | |
| from . import HelpMenu, group_n_channel, hellbot, on_message | |
| kickme_quotes = [ | |
| "โ๏ธ ๐ฎ๐๐๐๐บ ๐๐พ๐๐พ, ๐ ๐พ๐บ๐๐๐๐ ๐๐๐พ ๐๐๐บ๐๐พ ๐๐ ๐๐๐พ ๐๐พ๐บ๐ ๐๐๐บ๐๐!", | |
| "๐ ๐ค๐ ๐พ๐๐บ๐๐๐๐ ๐๐ ๐๐๐ป๐พ๐, ๐ ๐พ๐บ๐๐๐๐ ๐๐๐พ ๐ผ๐๐บ๐ ๐๐ ๐๐๐๐ ๐พ.", | |
| "๐๏ธ ๐ฅ๐ ๐๐๐๐ ๐๐๐ ๐, ๐พ๐๐๐๐๐๐ ๐๐๐๐ ๐๐๐๐๐ ๐๐๐บ๐ผ๐พ๐ฟ๐๐ ๐ ๐.", | |
| "๐ช๏ธ ๐ฒ๐๐๐๐๐๐๐ ๐๐ ๐๐๐พ ๐๐๐๐ฝ๐ ๐๐ฟ ๐ฝ๐พ๐๐บ๐๐๐๐๐พ, ๐ป๐๐พ!", | |
| "๐ถโโ๏ธ ๐ถ๐บ๐ ๐๐๐๐ ๐บ๐๐บ๐ ๐ ๐๐๐พ ๐บ ๐ป๐๐๐, ๐๐พ๐พ ๐๐๐ ๐๐พ๐๐พ๐!", | |
| "๐ฅ ๐ก๐๐๐๐๐๐ ๐ป๐๐๐ฝ๐๐พ๐ ๐บ๐๐ฝ ๐ผ๐๐พ๐บ๐๐๐๐ ๐๐ ๐๐๐ ๐๐บ๐๐. ๐ ๐ฝ๐๐๐!", | |
| "๐ซ ๐ณ๐๐๐๐๐๐ ๐๐๐พ ๐๐บ๐๐พ ๐บ๐๐ฝ ๐ผ๐ ๐๐๐๐๐ ๐๐๐๐ ๐ผ๐๐บ๐๐๐พ๐.", | |
| "๐ ๐ข๐๐๐๐'๐ ๐๐๐ ๐๐พ๐บ๐๐ ๐ฟ๐๐ ๐๐๐๐ ๐ผ๐๐บ๐. ๐จ'๐ ๐๐๐!", | |
| "๐โโ๏ธ ๐ฒ๐๐๐๐๐๐๐๐ ๐๐๐ ๐๐ฟ ๐๐พ๐๐พ ๐๐๐๐ ๐ฟ๐ ๐บ๐๐. ๐ข๐บ๐๐ผ๐ ๐๐๐ ๐๐พ๐๐พ๐!", | |
| "๐ค ๐ฒ๐บ๐๐ ๐๐๐ ๐บ๐๐บ๐ ๐ฟ๐๐๐ ๐๐๐๐ ๐๐๐๐๐ ๐ผ๐๐บ๐, ๐๐๐๐๐๐ ๐๐พ๐บ๐ ๐บ๐๐พ๐บ๐ฝ!", | |
| "๐ ๐ซ๐๐๐พ ๐บ ๐ ๐พ๐บ๐ฟ ๐๐ ๐๐๐พ ๐๐๐๐ฝ, ๐จ'๐ ๐ฝ๐๐๐ฟ๐๐๐๐ ๐บ๐๐บ๐. ๐ฅ๐บ๐๐พ๐๐พ๐ ๐ !", | |
| "๐ซ ๐ณ๐บ๐๐๐๐ ๐๐ฟ๐ฟ ๐ฟ๐๐๐ ๐๐๐๐ ๐ผ๐๐บ๐ ๐๐๐๐๐บ๐. ๐ก๐๐ ๐๐๐๐บ๐๐พ!", | |
| "๐ผ ๐ข๐ ๐๐๐๐๐ ๐๐๐พ ๐ป๐๐๐พ๐ฟ๐ผ๐บ๐๐พ ๐๐ ๐๐๐๐ ๐ผ๐๐บ๐. ๐ฏ๐๐๐ฟ๐พ๐๐๐๐๐๐บ๐ ๐พ๐๐๐!", | |
| "๐ญ ๐ค๐๐๐๐๐๐ ๐๐๐พ ๐๐๐บ๐๐พ ๐๐๐๐ ๐บ ๐ฝ๐๐บ๐๐บ๐๐๐ผ ๐ฟ๐ ๐บ๐๐. ๐ณ๐บ-๐ฝ๐บ!", | |
| "๐ถ ๐ฏ๐ ๐บ๐๐๐๐ ๐๐ ๐พ๐๐๐ ๐๐๐๐๐ผ. ๐ข๐๐พ ๐๐๐พ ๐ฟ๐บ๐๐พ๐๐พ๐ ๐ ๐๐๐๐๐๐๐๐!", | |
| "๐ถ๏ธ ๐ฅ๐บ๐ฝ๐๐๐ ๐๐๐๐ ๐๐๐พ ๐๐๐บ๐ฝ๐๐๐, ๐ ๐พ๐บ๐๐๐๐ ๐บ๐ ๐บ๐๐ ๐๐ฟ ๐๐๐๐๐พ๐๐.", | |
| "๐ช ๐ข๐ ๐๐๐๐๐ ๐๐๐พ ๐ฝ๐๐๐ ๐๐๐๐พ๐๐ ๐ ๐๐ ๐๐๐๐ ๐ผ๐๐บ๐. ๐ค๐๐๐ ๐ผ๐๐๐๐ ๐พ๐๐พ!", | |
| "๐ ๐ซ๐๐ผ๐๐๐๐ ๐๐๐พ ๐ผ๐๐บ๐ ๐ป๐พ๐๐๐๐ฝ ๐๐พ. ๐ช๐พ๐พ๐ ๐๐ ๐๐๐๐ ๐๐๐, ๐ฟ๐๐ ๐๐!", | |
| "๐ ๐ต๐บ๐๐๐๐๐๐๐ ๐๐๐๐ ๐๐๐พ ๐ผ๐๐๐๐๐ผ ๐บ๐ป๐๐๐. ๐ฒ๐พ๐พ ๐๐๐ ๐๐ ๐๐๐พ ๐๐๐บ๐๐!", | |
| "๐ ๐ก๐๐พ๐บ๐๐๐๐ ๐ฟ๐๐พ๐พ ๐ฟ๐๐๐ ๐๐๐๐ ๐ผ๐๐บ๐. ๐ด๐๐ ๐พ๐บ๐๐๐๐๐ ๐๐ ๐๐๐ ๐ ๐๐๐๐๐๐พ๐!", | |
| "๐ ๐ค๐๐๐๐๐๐ ๐๐๐บ๐ผ๐พ๐ฟ๐๐ ๐ ๐. ๐ณ๐๐๐ ๐ผ๐๐บ๐ ๐ผ๐๐๐ ๐ฝ๐'๐ ๐๐บ๐๐ฝ๐ ๐พ ๐๐ ๐๐๐๐ ๐พ.", | |
| "๐ ๐ณ๐๐๐พ ๐ฟ๐๐ ๐๐พ ๐๐ ๐ป๐ ๐บ๐๐ ๐๐ฟ๐ฟ. ๐ ๐ฝ๐๐๐, ๐บ๐๐๐๐๐!", | |
| "๐ช๏ธ ๐ฒ๐๐๐๐๐๐๐ ๐๐ ๐๐๐พ ๐ฝ๐๐บ๐๐บ ๐บ๐๐ฝ ๐๐บ๐๐๐๐ ๐๐ ๐พ๐๐๐.", | |
| ] | |
| async def setgpic(_, message: Message): | |
| if not message.reply_to_message or not message.reply_to_message.photo: | |
| return await hellbot.delete( | |
| message, "๐ฑ๐พ๐๐ ๐ ๐๐ ๐บ ๐๐๐๐๐ ๐๐ ๐๐พ๐ ๐บ๐ ๐๐๐๐๐ ๐๐๐๐ฟ๐๐ ๐พ ๐๐๐ผ๐๐๐๐พ." | |
| ) | |
| status = await message.chat.set_photo(photo=message.reply_to_message.photo.file_id) | |
| if not status: | |
| return await hellbot.delete(message, "๐ฒ๐๐๐๐, ๐๐๐๐พ๐๐๐๐๐ ๐๐พ๐๐ ๐๐๐๐๐.") | |
| await hellbot.delete(message, "๐ฒ๐๐ผ๐ผ๐พ๐๐๐ฟ๐๐ ๐ ๐ ๐๐พ๐ ๐๐๐๐๐ ๐๐๐๐ฟ๐๐ ๐พ ๐๐๐ผ๐๐๐๐พ.") | |
| await hellbot.check_and_log( | |
| "setgpic", | |
| f"**Group Profile Picture**\n\n**Group:** `{message.chat.title}`\n**Group ID:** `{message.chat.id}`\n**Admin:** `{message.from_user.mention}`", | |
| ) | |
| async def setgtitle(_, message: Message): | |
| if len(message.command) < 2: | |
| return await hellbot.delete( | |
| message, "๐จ ๐๐พ๐พ๐ฝ ๐๐๐๐พ๐๐๐๐๐ ๐๐ ๐๐พ๐ ๐๐๐๐ ๐๐๐๐๐ ๐๐๐๐ ๐พ." | |
| ) | |
| prev_title = message.chat.title | |
| new_title = await hellbot.input(message) | |
| status = await message.chat.set_title(new_title) | |
| if not status: | |
| return await hellbot.delete(message, "๐ฒ๐๐๐๐, ๐๐๐๐พ๐๐๐๐๐ ๐๐พ๐๐ ๐๐๐๐๐.") | |
| await hellbot.delete(message, "๐ฒ๐๐ผ๐ผ๐พ๐๐๐ฟ๐๐ ๐ ๐ ๐๐พ๐ ๐๐๐๐๐ ๐๐๐๐ ๐พ.") | |
| await hellbot.check_and_log( | |
| "setgtitle", | |
| f"**Group Title**\n\n**Group:** `{prev_title}`\n**Group ID:** `{message.chat.id}`\n**Admin:** `{message.from_user.mention}`", | |
| ) | |
| async def setgabout(_, message: Message): | |
| if len(message.command) < 2: | |
| return await hellbot.delete( | |
| message, "๐จ ๐๐พ๐พ๐ฝ ๐๐๐๐พ๐๐๐๐๐ ๐๐ ๐๐พ๐ ๐๐๐๐ ๐๐๐๐๐ ๐บ๐ป๐๐๐." | |
| ) | |
| new_about = await hellbot.input(message) | |
| status = await message.chat.set_description(new_about) | |
| if not status: | |
| return await hellbot.delete(message, "๐ฒ๐๐๐๐, ๐๐๐๐พ๐๐๐๐๐ ๐๐พ๐๐ ๐๐๐๐๐.") | |
| await hellbot.delete(message, "๐ฒ๐๐ผ๐ผ๐พ๐๐๐ฟ๐๐ ๐ ๐ ๐๐พ๐ ๐๐๐๐๐ ๐บ๐ป๐๐๐.") | |
| await hellbot.check_and_log( | |
| "setgabout", | |
| f"**Group About**\n\n**Group:** `{message.chat.title}`\n**Group ID:** `{message.chat.id}`\n**Admin:** `{message.from_user.mention}`", | |
| ) | |
| async def setgusername(client: Client, message: Message): | |
| user_status = (await message.chat.get_member(message.from_user.id)).status | |
| if user_status != ChatMemberStatus.OWNER: | |
| return await hellbot.delete(message, "๐จ ๐บ๐ ๐๐๐ ๐๐๐พ ๐๐๐๐พ๐ ๐๐ฟ ๐๐๐๐ ๐๐๐๐๐.") | |
| if len(message.command) < 2: | |
| return await hellbot.delete( | |
| message, "๐จ ๐๐พ๐พ๐ฝ ๐๐๐๐พ๐๐๐๐๐ ๐๐ ๐๐พ๐ ๐๐๐๐ ๐๐๐๐๐'๐ ๐๐๐พ๐๐๐บ๐๐พ." | |
| ) | |
| new_username = await hellbot.input(message) | |
| status = await client.set_chat_username(message.chat.id, new_username) | |
| if not status: | |
| return await hellbot.delete(message, "๐ฒ๐๐๐๐, ๐๐๐๐พ๐๐๐๐๐ ๐๐พ๐๐ ๐๐๐๐๐.") | |
| await hellbot.delete(message, "๐ฒ๐๐ผ๐ผ๐พ๐๐๐ฟ๐๐ ๐ ๐ ๐๐พ๐ ๐๐๐๐๐ ๐๐๐พ๐๐๐บ๐๐พ.") | |
| await hellbot.check_and_log( | |
| "setgusername", | |
| f"**Group Username**\n\n**Group:** `{message.chat.title}`\n**Group ID:** `{message.chat.id}`\n**Admin:** `{message.from_user.mention}`", | |
| ) | |
| async def getglink(_, message: Message): | |
| link = await message.chat.export_invite_link() | |
| await hellbot.delete(message, f"**๐ฆ๐๐๐๐ ๐ ๐๐๐:** `{link}`") | |
| async def kickme(client: Client, message: Message): | |
| hell = await hellbot.edit(message, random.choice(kickme_quotes)) | |
| try: | |
| await client.leave_chat(message.chat.id) | |
| except Exception as e: | |
| return await hellbot.delete( | |
| hell, f"Deym! Can't leave this chat.\n**Error:** `{e}`" | |
| ) | |
| async def new_group(client: Client, message: Message): | |
| if len(message.command) < 2: | |
| return await hellbot.delete(message, "๐จ ๐๐พ๐พ๐ฝ ๐๐๐๐พ๐๐๐๐๐ ๐๐ ๐๐พ๐ ๐บ๐ ๐๐๐๐๐ ๐๐๐๐ ๐พ.") | |
| new_title = await hellbot.input(message) | |
| try: | |
| new_group = await client.create_group(new_title, hellbot.bot.me.id) | |
| await hellbot.edit( | |
| message, f"**๐ฆ๐๐๐๐ ๐ ๐๐๐:** [{new_group.title}]({new_group.invite_link})" | |
| ) | |
| except Exception as e: | |
| await hellbot.error(message, f"`{e}`", 20) | |
| async def new_channel(client: Client, message: Message): | |
| if len(message.command) < 2: | |
| return await hellbot.delete( | |
| message, "๐จ ๐๐พ๐พ๐ฝ ๐๐๐๐พ๐๐๐๐๐ ๐๐ ๐๐พ๐ ๐บ๐ ๐ผ๐๐บ๐๐๐พ๐ ๐๐๐๐ ๐พ." | |
| ) | |
| new_title = await hellbot.input(message) | |
| try: | |
| new_channel = await client.create_channel(new_title, "Created by HellBot") | |
| await hellbot.edit( | |
| message, f"**๐ข๐๐บ๐๐๐พ๐ ๐ ๐๐๐:** [{new_channel.title}]({new_channel.username})" | |
| ) | |
| except Exception as e: | |
| await hellbot.error(message, f"`{e}`", 20) | |
| async def chatInfo(client: Client, message: Message): | |
| if len(message.command) > 1: | |
| try: | |
| chat = await client.get_chat(message.command[1]) | |
| except Exception as e: | |
| return await hellbot.error(message, f"`{e}`") | |
| else: | |
| chat = message.chat | |
| hell = await hellbot.edit(message, "Fetching chat info...") | |
| if chat.invite_link: | |
| chat_link = f"[Invite Link]({chat.invite_link})" | |
| elif chat.username: | |
| chat_link = f"@{chat.username}" | |
| else: | |
| chat_link = "Private Chat" | |
| chat_owner = None | |
| admins_count = 0 | |
| bots_count = 0 | |
| async for admin in client.get_chat_members( | |
| chat.id, filter=ChatMembersFilter.ADMINISTRATORS | |
| ): | |
| admins_count += 1 | |
| if admin.status == ChatMemberStatus.OWNER: | |
| chat_owner = admin.user.mention | |
| async for _ in client.get_chat_members(chat.id, filter=ChatMembersFilter.BOTS): | |
| bots_count += 1 | |
| chat_info = await chat_info_templates( | |
| chatName=chat.title, | |
| chatId=chat.id, | |
| chatLink=chat_link, | |
| chatOwner=chat_owner, | |
| dcId=chat.dc_id, | |
| membersCount=chat.members_count, | |
| adminsCount=admins_count, | |
| botsCount=bots_count, | |
| description=chat.description, | |
| ) | |
| if chat.photo: | |
| async for photo in client.get_chat_photos(chat.id, 1): | |
| await hell.delete() | |
| await client.send_photo( | |
| message.chat.id, | |
| photo.file_id, | |
| caption=chat_info, | |
| reply_to_message_id=message.id, | |
| disable_notification=True, | |
| ) | |
| return | |
| else: | |
| await hell.edit(chat_info, disable_web_page_preview=True) | |
| async def chatAdmins(client: Client, message: Message): | |
| if len(message.command) < 2: | |
| chat = message.chat | |
| else: | |
| try: | |
| chat = await client.get_chat(message.command[1]) | |
| except Exception as e: | |
| return await hellbot.error(message, f"`{e}`") | |
| hell = await hellbot.edit(message, "Fetching chat admins...") | |
| admin_count = 0 | |
| admins = "**๐ซ ๐ ๐ฝ๐๐๐๐ ๐๐ ๐๐๐๐ ๐ผ๐๐บ๐:**\n\n" | |
| async for admin in client.get_chat_members( | |
| chat.id, filter=ChatMembersFilter.ADMINISTRATORS | |
| ): | |
| admin_count += 1 | |
| admins += f"**{'0' if admin_count < 10 else ''}{admin_count}:** {admin.user.mention} - `{admin.status}`\n" | |
| await hell.edit(admins, disable_web_page_preview=True) | |
| async def chatBots(client: Client, message: Message): | |
| if len(message.command) < 2: | |
| chat = message.chat | |
| else: | |
| try: | |
| chat = await client.get_chat(message.command[1]) | |
| except Exception as e: | |
| return await hellbot.error(message, f"`{e}`") | |
| hell = await hellbot.edit(message, "Fetching chat bots...") | |
| bot_count = 0 | |
| bots = "**๐ค ๐ก๐๐๐ ๐๐ ๐๐๐๐ ๐ผ๐๐บ๐:**\n\n" | |
| async for bot in client.get_chat_members(chat.id, filter=ChatMembersFilter.BOTS): | |
| bot_count += 1 | |
| bots += ( | |
| f"**{'0' if bot_count < 10 else ''}{bot_count}:** @{bot.user.username}\n" | |
| ) | |
| await hell.edit(bots, disable_web_page_preview=True) | |
| async def chatId(_, message: Message): | |
| if message.reply_to_message: | |
| msg = message.reply_to_message | |
| else: | |
| msg = message | |
| hell = await hellbot.edit(message, "Fetching message info...") | |
| info = f"**๐ซ ChatID:** `{msg.chat.id}`\n" | |
| info += f"**๐ชช MessageID:** `{msg.id}`\n\n" | |
| if msg.from_user: | |
| info += f"**๐ค UserID:** `{msg.from_user.id}`\n\n" | |
| if msg.forward_from: | |
| info += f"**๐ค Forwarded From:** `{msg.forward_from.id}`\n\n" | |
| if msg.forward_from_chat: | |
| info += f"**๐ซ Forwarded ChatID:** `{msg.forward_from_chat.id}`\n\n" | |
| file_id = await get_media_fileid(msg) | |
| if file_id: | |
| info += f"**๐ FileID:** `{file_id}`\n\n" | |
| await hell.edit(info, disable_web_page_preview=True) | |
| async def inviteUser(client: Client, message: Message): | |
| if len(message.command) < 2: | |
| return await hellbot.delete( | |
| message, "I need a username/id to invite to this chat." | |
| ) | |
| users = (await hellbot.input(message)).split(" ") | |
| hell = await hellbot.edit(message, "Inviting users...") | |
| resolved_users = await client.get_users(users) | |
| await message.chat.add_members([user.id for user in resolved_users]) | |
| await hell.edit("Successfully invited users to this chat.") | |
| HelpMenu("groups").add( | |
| "setgpic", "<reply to photo>", "Set the group profile picture.", "setgpic" | |
| ).add("setgtitle", "<title>", "Set the group title.", "setgtitle chat group").add( | |
| "setgabout", | |
| "<text>", | |
| "Set the group description/about", | |
| "setgabout some group description", | |
| ).add( | |
| "setgusername", | |
| "<username>", | |
| "Set the group username.", | |
| "setgusername HellBot_Chats", | |
| "Only group owners can use this command. Give username without '@'.", | |
| ).add( | |
| "getglink", None, "Get the group invite link.", "getglink" | |
| ).add( | |
| "kickme", None, "Leave the chat in swag ๐!", "kickme" | |
| ).add( | |
| "newgroup", "<title>", "Create a new group.", "newgroup HellBot Group" | |
| ).add( | |
| "newchannel", "<title>", "Create a new channel.", "newchannel HellBot Channel" | |
| ).add( | |
| "chatinfo", "<chat id (optional)>", "Get info about the chat.", "chatinfo" | |
| ).add( | |
| "chatadmins", | |
| "<chat id (optional)>", | |
| "Get the list of admins of mentioned chat.", | |
| "chatadmins @Hellbot_Chats", | |
| ).add( | |
| "chatbots", | |
| "<chat id (optional)>", | |
| "Get the list of bots of mentioned chat.", | |
| "chatbots @Hellbot_Chats", | |
| ).add( | |
| "id", | |
| "<reply to message (optional)>", | |
| "Get the ID of the replied message, replied user, and more.", | |
| "id", | |
| ).add( | |
| "invite", | |
| "<username/id>", | |
| "Invite the mentioned user to this chat.", | |
| "invite @ForGo10God", | |
| "You can invite multiple users by giving their username/id separated by space.", | |
| ).info( | |
| "Group Menu" | |
| ).done() | |