Skip to content

Commit

Permalink
Speedtest
Browse files Browse the repository at this point in the history
  • Loading branch information
5hojib committed Jan 2, 2025
1 parent f8464c3 commit 376cff2
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 95 deletions.
1 change: 1 addition & 0 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"StatsCommand": "- Check Bot & System stats",
"CancelAllCommand": "- Cancel all tasks added by you to the bot",
"HelpCommand": "- Get detailed help",
"SpeedTest": "- Get speedtest result",
"BotSetCommand": "- [ADMIN] Open Bot settings",
"LogCommand": "- [ADMIN] View log",
"RestartCommand": "- [ADMIN] Restart the bot",
Expand Down
5 changes: 5 additions & 0 deletions bot/core/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ def add_handlers():
BotCommands.MediaInfoCommand,
CustomFilters.authorized,
),
"speedtest": (
speedtest,
BotCommands.SpeedTest,
CustomFilters.authorized,
),
}

for handler_func, command_name, custom_filter in command_filters.values():
Expand Down
1 change: 1 addition & 0 deletions bot/helper/telegram_helper/bot_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(self):
self.ClearLocalsCommand = f"clearlocals{i}"
self.BotSetCommand = f"botsettings{i}"
self.UserSetCommand = f"settings{i}"
self.SpeedTest = f"speedtest{i}"
self.SelectCommand = f"sel{i}"
self.RssCommand = f"rss{i}"

Expand Down
172 changes: 87 additions & 85 deletions bot/modules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,85 +1,87 @@
from .bot_settings import edit_bot_settings, send_bot_settings
from .cancel_task import cancel, cancel_all_buttons, cancel_all_update, cancel_multi
from .chat_permission import add_sudo, authorize, remove_sudo, unauthorize
from .clone import clone_node
from .exec import aioexecute, clear, execute
from .file_selector import confirm_selection, select
from .force_start import remove_from_queue
from .gd_count import count_node
from .gd_delete import delete_file
from .gd_search import gdrive_search, select_type
from .help import arg_usage, bot_help
from .mediainfo import mediainfo
from .mirror_leech import (
leech,
mirror,
)
from .restart import (
confirm_restart,
restart_bot,
restart_notification,
restart_sessions,
)
from .rss import get_rss_menu, rss_listener
from .search import initiate_search_tools, torrent_search, torrent_search_update
from .services import log, ping, start
from .shell import run_shell
from .stats import bot_stats, get_packages_version
from .status import status_pages, task_status
from .users_settings import (
edit_user_settings,
get_users_settings,
send_user_settings,
)
from .ytdlp import ytdl, ytdl_leech

__all__ = [
"add_sudo",
"aioexecute",
"arg_usage",
"authorize",
"bot_help",
"bot_stats",
"cancel",
"cancel_all_buttons",
"cancel_all_update",
"cancel_multi",
"clear",
"clone_node",
"confirm_restart",
"confirm_selection",
"count_node",
"delete_file",
"edit_bot_settings",
"edit_user_settings",
"execute",
"gdrive_search",
"get_packages_version",
"get_rss_menu",
"get_users_settings",
"initiate_search_tools",
"leech",
"log",
"mediainfo",
"mirror",
"ping",
"remove_from_queue",
"remove_sudo",
"restart_bot",
"restart_notification",
"restart_sessions",
"rss_listener",
"run_shell",
"select",
"select_type",
"send_bot_settings",
"send_user_settings",
"start",
"status_pages",
"task_status",
"torrent_search",
"torrent_search_update",
"unauthorize",
"ytdl",
"ytdl_leech",
]
from .bot_settings import edit_bot_settings, send_bot_settings
from .cancel_task import cancel, cancel_all_buttons, cancel_all_update, cancel_multi
from .chat_permission import add_sudo, authorize, remove_sudo, unauthorize
from .clone import clone_node
from .exec import aioexecute, clear, execute
from .file_selector import confirm_selection, select
from .force_start import remove_from_queue
from .gd_count import count_node
from .gd_delete import delete_file
from .gd_search import gdrive_search, select_type
from .help import arg_usage, bot_help
from .mediainfo import mediainfo
from .mirror_leech import (
leech,
mirror,
)
from .restart import (
confirm_restart,
restart_bot,
restart_notification,
restart_sessions,
)
from .rss import get_rss_menu, rss_listener
from .search import initiate_search_tools, torrent_search, torrent_search_update
from .services import log, ping, start
from .shell import run_shell
from .speedtest import speedtest
from .stats import bot_stats, get_packages_version
from .status import status_pages, task_status
from .users_settings import (
edit_user_settings,
get_users_settings,
send_user_settings,
)
from .ytdlp import ytdl, ytdl_leech

__all__ = [
"add_sudo",
"aioexecute",
"arg_usage",
"authorize",
"bot_help",
"bot_stats",
"cancel",
"cancel_all_buttons",
"cancel_all_update",
"cancel_multi",
"clear",
"clone_node",
"confirm_restart",
"confirm_selection",
"count_node",
"delete_file",
"edit_bot_settings",
"edit_user_settings",
"execute",
"gdrive_search",
"get_packages_version",
"get_rss_menu",
"get_users_settings",
"initiate_search_tools",
"leech",
"log",
"mediainfo",
"mirror",
"ping",
"remove_from_queue",
"remove_sudo",
"restart_bot",
"restart_notification",
"restart_sessions",
"rss_listener",
"run_shell",
"select",
"select_type",
"send_bot_settings",
"send_user_settings",
"speedtest",
"start",
"status_pages",
"task_status",
"torrent_search",
"torrent_search_update",
"unauthorize",
"ytdl",
"ytdl_leech",
]
12 changes: 2 additions & 10 deletions bot/modules/speedtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pyrogram.handlers import MessageHandler
from speedtest import Speedtest

from bot import LOGGER, bot
from bot import LOGGER
from bot.helper.ext_utils.bot_utils import new_task
from bot.helper.ext_utils.status_utils import get_readable_file_size
from bot.helper.telegram_helper.bot_commands import BotCommands
Expand All @@ -25,7 +25,7 @@ def get_speedtest_results():
test.upload()
return test.results

result = await bot.loop.run_in_executor(None, get_speedtest_results)
result = get_speedtest_results

if not result:
await edit_message(speed, "Speedtest failed to complete.")
Expand All @@ -43,11 +43,3 @@ def get_speedtest_results():
except Exception as e:
LOGGER.error(str(e))
await edit_message(speed, string_speed)


bot.add_handler(
MessageHandler(
speedtest,
filters=command(BotCommands.SpeedCommand) & CustomFilters.authorized,
),
)

0 comments on commit 376cff2

Please sign in to comment.