Skip to content

Commit

Permalink
Improve help message
Browse files Browse the repository at this point in the history
Request by mf juned

Signed-off-by: anasty17 <[email protected]>
  • Loading branch information
anasty17 committed Dec 13, 2023
1 parent f8c18c5 commit 3504c0a
Show file tree
Hide file tree
Showing 7 changed files with 282 additions and 260 deletions.
31 changes: 16 additions & 15 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
from aiofiles.os import path as aiopath, remove as aioremove
from aiofiles import open as aiopen
from os import execl as osexecl
from time import time
from sys import executable
from pyrogram.handlers import MessageHandler
from pyrogram.filters import command
from asyncio import create_subprocess_exec, gather
from psutil import (
disk_usage,
cpu_percent,
Expand All @@ -11,12 +16,16 @@
net_io_counters,
boot_time,
)
from time import time
from sys import executable
from pyrogram.handlers import MessageHandler
from pyrogram.filters import command
from asyncio import create_subprocess_exec, gather

from .helper.ext_utils.files_utils import clean_all, exit_clean_up
from .helper.ext_utils.bot_utils import cmd_exec, sync_to_async, create_help_buttons
from .helper.ext_utils.status_utils import get_readable_file_size, get_readable_time
from .helper.ext_utils.db_handler import DbManger
from .helper.telegram_helper.bot_commands import BotCommands
from .helper.telegram_helper.message_utils import sendMessage, editMessage, sendFile
from .helper.telegram_helper.filters import CustomFilters
from .helper.telegram_helper.button_build import ButtonMaker
from bot.helper.listeners.aria2_listener import start_aria2_listener
from bot import (
bot,
botStartTime,
Expand All @@ -27,15 +36,6 @@
INCOMPLETE_TASK_NOTIFIER,
scheduler,
)
from .helper.ext_utils.files_utils import clean_all, exit_clean_up
from .helper.ext_utils.bot_utils import cmd_exec, sync_to_async, initiate_help_messages
from .helper.ext_utils.status_utils import get_readable_file_size, get_readable_time
from .helper.ext_utils.db_handler import DbManger
from .helper.telegram_helper.bot_commands import BotCommands
from .helper.telegram_helper.message_utils import sendMessage, editMessage, sendFile
from .helper.telegram_helper.filters import CustomFilters
from .helper.telegram_helper.button_build import ButtonMaker
from bot.helper.listeners.aria2_listener import start_aria2_listener
from .modules import (
authorize,
cancel_task,
Expand All @@ -53,6 +53,7 @@
eval,
users_settings,
bot_settings,
help,
)


Expand Down Expand Up @@ -231,8 +232,8 @@ async def main():
clean_all(),
torrent_search.initiate_search_tools(),
restart_notification(),
initiate_help_messages(),
)
create_help_buttons()
await sync_to_async(start_aria2_listener, wait=False)

bot.add_handler(MessageHandler(start, filters=command(BotCommands.StartCommand)))
Expand Down
39 changes: 14 additions & 25 deletions bot/helper/ext_utils/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@
create_subprocess_shell,
run_coroutine_threadsafe,
sleep,
gather,
)
from asyncio.subprocess import PIPE
from functools import partial, wraps
from concurrent.futures import ThreadPoolExecutor
from aiohttp import ClientSession

from bot import user_data, config_dict, bot_loop
from bot.helper.ext_utils.help_messages import YT_HELP_DICT, MIRROR_HELP_DICT
from bot.helper.telegram_helper.button_build import ButtonMaker
from bot.helper.ext_utils.telegraph_helper import telegraph
from bot.helper.ext_utils.help_messages import (
MIRROR_HELP_MESSAGE,
YT_HELP_MESSAGE,
CLONE_HELP_MESSAGE,
)

THREADPOOL = ThreadPoolExecutor(max_workers=1000)

Expand All @@ -39,6 +34,19 @@ def cancel(self):
self.task.cancel()


def create_help_buttons():
buttons = ButtonMaker()
for name in list(MIRROR_HELP_DICT.keys())[1:]:
buttons.ibutton(name, f"help m {name}")
buttons.ibutton("Close", f"help close")
COMMAND_USAGE["mirror"] = [MIRROR_HELP_DICT["main"], buttons.build_menu(3)]
buttons.reset()
for name in list(YT_HELP_DICT.keys())[1:]:
buttons.ibutton(name, f"help yt {name}")
buttons.ibutton("Close", f"help close")
COMMAND_USAGE["yt"] = [YT_HELP_DICT["main"], buttons.build_menu(3)]


def bt_selection_buttons(id_):
gid = id_[:12] if len(id_) > 20 else id_
pincode = "".join([n for n in id_ if n.isdigit()][:4])
Expand All @@ -56,25 +64,6 @@ def bt_selection_buttons(id_):
return buttons.build_menu(2)


async def initiate_help_messages():
mirror, yt, clone = await gather(
telegraph.create_page(
title="Mirror-Leech Command Usage", content=MIRROR_HELP_MESSAGE
),
telegraph.create_page(title="YTDLP Command Usage", content=YT_HELP_MESSAGE),
telegraph.create_page(title="Clone Command Usage", content=CLONE_HELP_MESSAGE),
)
buttons = ButtonMaker()
buttons.ubutton("Usage Guide", f"https://telegra.ph/{mirror['path']}")
COMMAND_USAGE["main"] = buttons.build_menu(1)
buttons.reset()
buttons.ubutton("Usage Guide", f"https://telegra.ph/{yt['path']}")
COMMAND_USAGE["yt"] = buttons.build_menu(1)
buttons.reset()
buttons.ubutton("Usage Guide", f"https://telegra.ph/{clone['path']}")
COMMAND_USAGE["clone"] = buttons.build_menu(1)


async def get_telegraph_list(telegraph_content):
path = [
(
Expand Down
Loading

1 comment on commit 3504c0a

@junedkh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love you brother ❤️❤️❤️

Please sign in to comment.