From 092b67a392005db7d34ed53942f850a7c5df2534 Mon Sep 17 00:00:00 2001 From: Juan <72490350+jusidama18@users.noreply.github.com> Date: Wed, 15 Sep 2021 20:06:40 +0700 Subject: [PATCH] Move Command to Telegraph --- bot/__main__.py | 140 ++++++++++++++++++------------------------------ 1 file changed, 51 insertions(+), 89 deletions(-) diff --git a/bot/__main__.py b/bot/__main__.py index 8f87752..c82408a 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -6,10 +6,11 @@ import asyncio from pyrogram import idle from sys import executable -from telegram import ParseMode +from telegram import ParseMode, InlineKeyboardMarkup from telegram.ext import CommandHandler +from telegraph import Telegraph from wserver import start_server_async -from bot import bot, app, dispatcher, updater, botStartTime, IGNORE_PENDING_REQUESTS, IS_VPS, PORT, alive, web, OWNER_ID, AUTHORIZED_CHATS +from bot import bot, app, dispatcher, updater, botStartTime, IGNORE_PENDING_REQUESTS, IS_VPS, PORT, alive, web, OWNER_ID, AUTHORIZED_CHATS, telegraph_token from bot.helper.ext_utils import fs_utils from bot.helper.telegram_helper.bot_commands import BotCommands from bot.helper.telegram_helper.message_utils import * @@ -86,47 +87,49 @@ def log(update, context): def bot_help(update, context): - help_string_adm = f''' -/{BotCommands.HelpCommand}: To get this message - -/{BotCommands.MirrorCommand} [download_url][magnet_link]: Start mirroring the link to Google Drive. - -/{BotCommands.TarMirrorCommand} [download_url][magnet_link]: Start mirroring and upload the archived (.tar) version of the download - -/{BotCommands.ZipMirrorCommand} [download_url][magnet_link]: Start mirroring and upload the archived (.zip) version of the download - -/{BotCommands.UnzipMirrorCommand} [download_url][magnet_link]: Starts mirroring and if downloaded file is any archive, extracts it to Google Drive - -/{BotCommands.QbMirrorCommand} [download_url][magnet_link]: Start Mirroring using qBittorrent, Use /{BotCommands.QbMirrorCommand} s to select files before downloading - -/{BotCommands.QbTarMirrorCommand} [download_url][magnet_link]: Start mirroring using qBittorrent and upload the archived (.tar) version of the download - -/{BotCommands.QbZipMirrorCommand} [download_url][magnet_link]: Start mirroring using qBittorrent and upload the archived (.zip) version of the download - -/{BotCommands.QbUnzipMirrorCommand} [download_url][magnet_link]: Starts mirroring using qBittorrent and if downloaded file is any archive, extracts it to Google Drive - -/{BotCommands.CloneCommand} [drive_url]: Copy file/folder to Google Drive - -/{BotCommands.CountCommand} [drive_url]: Count file/folder of Google Drive Links - -/{BotCommands.DeleteCommand} [drive_url]: Delete file from Google Drive (Only Owner & Sudo) - -/{BotCommands.WatchCommand} [youtube-dl supported link]: Mirror through youtube-dl. Click /{BotCommands.WatchCommand} for more help - -/{BotCommands.TarWatchCommand} [youtube-dl supported link]: Mirror through youtube-dl and tar before uploading - -/{BotCommands.ZipWatchCommand} [youtube-dl supported link]: Mirror through youtube-dl and zip before uploading - -/{BotCommands.CancelMirror}: Reply to the message by which the download was initiated and that download will be cancelled - -/{BotCommands.CancelAllCommand}: Cancel all running tasks - -/{BotCommands.ListCommand} [search term]: Searches the search term in the Google Drive, If found replies with the link - -/{BotCommands.StatusCommand}: Shows a status of all the downloads - -/{BotCommands.StatsCommand}: Show Stats of the machine the bot is hosted on + help_string_telegraph = f'''
+/{BotCommands.HelpCommand}: To get this message +

+/{BotCommands.MirrorCommand} [download_url][magnet_link]: Start mirroring the link to Google Drive. +

+/{BotCommands.TarMirrorCommand} [download_url][magnet_link]: Start mirroring and upload the archived (.tar) version of the download +

+/{BotCommands.ZipMirrorCommand} [download_url][magnet_link]: Start mirroring and upload the archived (.zip) version of the download +

+/{BotCommands.UnzipMirrorCommand} [download_url][magnet_link]: Starts mirroring and if downloaded file is any archive, extracts it to Google Drive +

+/{BotCommands.QbMirrorCommand} [magnet_link]: Start Mirroring using qBittorrent, Use /{BotCommands.QbMirrorCommand} s to select files before downloading +

+/{BotCommands.QbTarMirrorCommand} [magnet_link]: Start mirroring using qBittorrent and upload the archived (.tar) version of the download +

+/{BotCommands.QbZipMirrorCommand} [magnet_link]: Start mirroring using qBittorrent and upload the archived (.zip) version of the download +

+/{BotCommands.QbUnzipMirrorCommand} [magnet_link]: Starts mirroring using qBittorrent and if downloaded file is any archive, extracts it to Google Drive +

+/{BotCommands.CloneCommand} [drive_url]: Copy file/folder to Google Drive +

+/{BotCommands.CountCommand} [drive_url]: Count file/folder of Google Drive Links +

+/{BotCommands.DeleteCommand} [drive_url]: Delete file from Google Drive (Only Owner & Sudo) +

+/{BotCommands.WatchCommand} [youtube-dl supported link]: Mirror through youtube-dl. Click /{BotCommands.WatchCommand} for more help +

+/{BotCommands.TarWatchCommand} [youtube-dl supported link]: Mirror through youtube-dl and tar before uploading +

+/{BotCommands.ZipWatchCommand} [youtube-dl supported link]: Mirror through youtube-dl and zip before uploading +

+/{BotCommands.CancelMirror}: Reply to the message by which the download was initiated and that download will be cancelled +

+/{BotCommands.CancelAllCommand}: Cancel all running tasks +

+/{BotCommands.ListCommand} [search term]: Searches the search term in the Google Drive, If found replies with the link +

+/{BotCommands.StatusCommand}: Shows a status of all the downloads +

+/{BotCommands.StatsCommand}: Show Stats of the machine the bot is hosted on +''' + help_string = f''' /{BotCommands.PingCommand}: Check how long it takes to Ping the Bot /{BotCommands.AuthorizeCommand}: Authorize a chat or a user to use the bot (Can only be invoked by Owner & Sudo of the bot) @@ -151,53 +154,12 @@ def bot_help(update, context): /{BotCommands.TsHelpCommand}: Get help for Torrent search module ''' - - help_string = f''' -/{BotCommands.HelpCommand}: To get this message - -/{BotCommands.MirrorCommand} [download_url][magnet_link]: Start mirroring the link to Google Drive. Use /{BotCommands.MirrorCommand} qb to mirror with qBittorrent, and use /{BotCommands.MirrorCommand} qbs to select files before downloading - -/{BotCommands.TarMirrorCommand} [download_url][magnet_link]: Start mirroring and upload the archived (.tar) version of the download - -/{BotCommands.ZipMirrorCommand} [download_url][magnet_link]: Start mirroring and upload the archived (.zip) version of the download - -/{BotCommands.UnzipMirrorCommand} [download_url][magnet_link]: Starts mirroring and if downloaded file is any archive, extracts it to Google Drive - -/{BotCommands.QbMirrorCommand} [download_url][magnet_link]: Start Mirroring using qBittorrent, Use /{BotCommands.QbMirrorCommand} s to select files before downloading - -/{BotCommands.QbTarMirrorCommand} [download_url][magnet_link]: Start mirroring using qBittorrent and upload the archived (.tar) version of the download - -/{BotCommands.QbZipMirrorCommand} [download_url][magnet_link]: Start mirroring using qBittorrent and upload the archived (.zip) version of the download - -/{BotCommands.QbUnzipMirrorCommand} [download_url][magnet_link]: Starts mirroring using qBittorrent and if downloaded file is any archive, extracts it to Google Drive - -/{BotCommands.CloneCommand} [drive_url]: Copy file/folder to Google Drive - -/{BotCommands.CountCommand} [drive_url]: Count file/folder of Google Drive Links - -/{BotCommands.WatchCommand} [youtube-dl supported link]: Mirror through youtube-dl. Click /{BotCommands.WatchCommand} for more help - -/{BotCommands.TarWatchCommand} [youtube-dl supported link]: Mirror through youtube-dl and tar before uploading - -/{BotCommands.ZipWatchCommand} [youtube-dl supported link]: Mirror through youtube-dl and zip before uploading - -/{BotCommands.CancelMirror}: Reply to the message by which the download was initiated and that download will be cancelled - -/{BotCommands.ListCommand} [search term]: Searches the search term in the Google Drive, If found replies with the link - -/{BotCommands.StatusCommand}: Shows a status of all the downloads - -/{BotCommands.StatsCommand}: Show Stats of the machine the bot is hosted on - -/{BotCommands.PingCommand}: Check how long it takes to Ping the Bot - -/{BotCommands.TsHelpCommand}: Get help for Torrent search module -''' - - if CustomFilters.sudo_user(update) or CustomFilters.owner_filter(update): - sendMessage(help_string_adm, context.bot, update) - else: - sendMessage(help_string, context.bot, update) + help = Telegraph(access_token=telegraph_token).create_page(title = 'Slam Mirrorbot Search', author_name='Slam Mirrorbot', + author_url='https://github.com/SlamDevs/slam-mirrorbot', html_content=help_string_telegraph)["path"] + button = button_build.ButtonMaker() + button.buildbutton("Other Commands", f"https://telegra.ph/{help}") + reply_markup = InlineKeyboardMarkup(button.build_menu(1)) + sendMarkup(help_string, context.bot, update, reply_markup) ''' botcmds = [