import asyncio from pyrogram import * from pyrogram.types import * from prettytable import PrettyTable from pyrogram import Client, enums, filters from pyrogram.types import Message from pyrogram.errors import * from config import * from akn import CMD_HELP, app, log_detailed_error from akn.utils.handler import * from akn.utils.helps import * from akn.utils.prefixprem import command from akn.Akeno.helper.PyroHelpers import ReplyCheck from akn.Akeno.helper.utility import split_list @Akeno( ~filters.scheduled & command(["help"]) & filters.me & ~filters.forwarded ) async def help_cmd(_, message: Message): args, _ = get_args(message) try: if not args: msg_edited = False for text in modules_help.help(): if msg_edited: await message.reply(text, disable_web_page_preview=True) else: await message.edit(text, disable_web_page_preview=True) msg_edited = True elif args[0] in modules_help.modules: await message.edit(modules_help.module_help(args[0]), disable_web_page_preview=True) else: await message.edit(modules_help.command_help(args[0]), disable_web_page_preview=True) except ValueError as e: await message.edit(e) async def edit_or_reply(message: Message, *args, **kwargs) -> Message: xyz = ( message.edit_text if bool(message.from_user and message.from_user.is_self or message.outgoing) else (message.reply_to_message or message).reply_text ) return await xyz(*args, **kwargs) @Akeno( ~filters.scheduled & command(["menu"]) & filters.me & ~filters.forwarded ) async def module_help(client: Client, message: Message): cmd = message.command user_id = message.from_user.id help_arg = "" bot_username = (await app.get_me()).username if len(cmd) > 1: help_arg = " ".join(cmd[1:]) elif not message.reply_to_message and len(cmd) == 1: await message.edit_text("⚡️") try: nice = await client.get_inline_bot_results(bot=bot_username, query="helper") await asyncio.gather( message.delete(), client.send_inline_bot_result( message.chat.id, nice.query_id, nice.results[0].id ), ) except BotResponseTimeout: await message.edit_text("Error BotResponseTimeout") except BaseException as e: await log_detailed_error(e, where=client.me.id, who=message.chat.title) return if help_arg: if help_arg in CMD_HELP: username = "©️ Copyright 2020-2023" commands: dict = CMD_HELP[help_arg] this_command = f"──「 **Help For {str(help_arg).upper()}** 」──\n\n" for x in commands: this_command += f" • **Command:** `.{str(x)}`\n • **Function:** `{str(commands[x])}`\n\n" this_command += "{}".format(username) await edit_or_reply( message, this_command, parse_mode=enums.ParseMode.MARKDOWN ) else: await edit_or_reply( message, f"`{help_arg}` **Not a Valid Module Name.**", ) def add_command_help(module_name, commands): if module_name in CMD_HELP.keys(): command_dict = CMD_HELP[module_name] else: command_dict = {} for x in commands: for y in x: if y is not x: command_dict[x[0]] = x[1] CMD_HELP[module_name] = command_dict module = modules_help.add_module("help", __file__) module.add_command("help", "Get common/module/command help.")