From 27fa460ea3d77f41ac00d3a382edad3ad26bae80 Mon Sep 17 00:00:00 2001 From: anasty17 Date: Tue, 3 Sep 2024 15:17:22 +0300 Subject: [PATCH] Fix new_task deco Signed-off-by: anasty17 --- bot/__main__.py | 14 +++++++------- bot/helper/ext_utils/bot_utils.py | 16 ++-------------- .../download_utils/jd_download.py | 4 ++-- .../mirror_leech_utils/gdrive_utils/list.py | 4 ++-- .../mirror_leech_utils/rclone_utils/list.py | 8 ++------ bot/modules/authorize.py | 10 +++++----- bot/modules/bot_settings.py | 18 +++++++++--------- bot/modules/cancel_task.py | 10 +++++----- bot/modules/exec.py | 8 ++++---- bot/modules/file_selector.py | 6 +++--- bot/modules/force_start.py | 4 ++-- bot/modules/gd_count.py | 4 ++-- bot/modules/gd_delete.py | 4 ++-- bot/modules/gd_search.py | 10 ++++++---- bot/modules/help.py | 4 ++-- bot/modules/rss.py | 17 +++++++++-------- bot/modules/shell.py | 4 ++-- bot/modules/status.py | 6 +++--- bot/modules/torrent_search.py | 6 +++--- bot/modules/users_settings.py | 18 +++++++++--------- bot/modules/ytdlp.py | 4 ++-- 21 files changed, 83 insertions(+), 96 deletions(-) diff --git a/bot/__main__.py b/bot/__main__.py index d4fadd4cec4..bc002592da5 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -31,7 +31,7 @@ cmd_exec, sync_to_async, create_help_buttons, - handler_new_task, + new_task, ) from .helper.ext_utils.db_handler import database from .helper.ext_utils.files_utils import clean_all, exit_clean_up @@ -63,7 +63,7 @@ ) -@handler_new_task +@new_task async def stats(_, message): if await aiopath.exists(".git"): last_commit = await cmd_exec( @@ -96,7 +96,7 @@ async def stats(_, message): await send_message(message, stats) -@handler_new_task +@new_task async def start(client, message): buttons = ButtonMaker() buttons.url_button( @@ -118,7 +118,7 @@ async def start(client, message): ) -@handler_new_task +@new_task async def restart(_, message): intervals["stopAll"] = True restart_message = await send_message(message, "Restarting...") @@ -153,7 +153,7 @@ async def restart(_, message): osexecl(executable, executable, "-m", "bot") -@handler_new_task +@new_task async def ping(_, message): start_time = int(round(time() * 1000)) reply = await send_message(message, "Starting Ping") @@ -161,7 +161,7 @@ async def ping(_, message): await edit_message(reply, f"{end_time - start_time} ms") -@handler_new_task +@new_task async def log(_, message): await send_file(message, "log.txt") @@ -207,7 +207,7 @@ async def log(_, message): """ -@handler_new_task +@new_task async def bot_help(_, message): await send_message(message, help_string) diff --git a/bot/helper/ext_utils/bot_utils.py b/bot/helper/ext_utils/bot_utils.py index f4d87a08c26..c25a4638fea 100644 --- a/bot/helper/ext_utils/bot_utils.py +++ b/bot/helper/ext_utils/bot_utils.py @@ -192,23 +192,11 @@ async def cmd_exec(cmd, shell=False): return stdout, stderr, proc.returncode -def handler_new_task(func): - @wraps(func) - async def wrapper(*args, **kwargs): - bot_loop.create_task(func(*args, **kwargs)) - - async def dummy(): - pass - - return dummy - - return wrapper - - def new_task(func): @wraps(func) async def wrapper(*args, **kwargs): - return bot_loop.create_task(func(*args, **kwargs)) + task = bot_loop.create_task(func(*args, **kwargs)) + return task return wrapper diff --git a/bot/helper/mirror_leech_utils/download_utils/jd_download.py b/bot/helper/mirror_leech_utils/download_utils/jd_download.py index 1e20d478cd0..a5cdbfa2597 100644 --- a/bot/helper/mirror_leech_utils/download_utils/jd_download.py +++ b/bot/helper/mirror_leech_utils/download_utils/jd_download.py @@ -16,7 +16,7 @@ jd_lock, jd_downloads, ) -from ...ext_utils.bot_utils import retry_function, handler_new_task +from ...ext_utils.bot_utils import retry_function, new_task from ...ext_utils.jdownloader_booter import jdownloader from ...ext_utils.task_manager import check_running_tasks, stop_duplicate_check from ...listeners.jdownloader_listener import on_download_start @@ -31,7 +31,7 @@ ) -@handler_new_task +@new_task async def configureDownload(_, query, obj): data = query.data.split() message = query.message diff --git a/bot/helper/mirror_leech_utils/gdrive_utils/list.py b/bot/helper/mirror_leech_utils/gdrive_utils/list.py index d9920b41b6a..cffc95b5679 100644 --- a/bot/helper/mirror_leech_utils/gdrive_utils/list.py +++ b/bot/helper/mirror_leech_utils/gdrive_utils/list.py @@ -9,7 +9,7 @@ from time import time from bot import config_dict -from ...ext_utils.bot_utils import update_user_ldata, handler_new_task +from ...ext_utils.bot_utils import update_user_ldata, new_task from ...ext_utils.db_handler import database from ...ext_utils.status_utils import get_readable_file_size, get_readable_time from ...mirror_leech_utils.gdrive_utils.helper import GoogleDriveHelper @@ -25,7 +25,7 @@ LIST_LIMIT = 6 -@handler_new_task +@new_task async def id_updates(_, query, obj): await query.answer() message = query.message diff --git a/bot/helper/mirror_leech_utils/rclone_utils/list.py b/bot/helper/mirror_leech_utils/rclone_utils/list.py index 555b818fc0d..0b547ddea61 100644 --- a/bot/helper/mirror_leech_utils/rclone_utils/list.py +++ b/bot/helper/mirror_leech_utils/rclone_utils/list.py @@ -9,11 +9,7 @@ from time import time from bot import LOGGER, config_dict -from ...ext_utils.bot_utils import ( - cmd_exec, - handler_new_task, - update_user_ldata, -) +from ...ext_utils.bot_utils import cmd_exec, update_user_ldata, new_task from ...ext_utils.db_handler import database from ...ext_utils.status_utils import get_readable_file_size, get_readable_time from ...telegram_helper.button_build import ButtonMaker @@ -26,7 +22,7 @@ LIST_LIMIT = 6 -@handler_new_task +@new_task async def path_updates(_, query, obj): await query.answer() message = query.message diff --git a/bot/modules/authorize.py b/bot/modules/authorize.py index 4b5f94de9a5..9b97d196273 100644 --- a/bot/modules/authorize.py +++ b/bot/modules/authorize.py @@ -2,14 +2,14 @@ from pyrogram.handlers import MessageHandler from bot import user_data, config_dict, bot -from ..helper.ext_utils.bot_utils import update_user_ldata, handler_new_task +from ..helper.ext_utils.bot_utils import update_user_ldata, new_task from ..helper.ext_utils.db_handler import database from ..helper.telegram_helper.bot_commands import BotCommands from ..helper.telegram_helper.filters import CustomFilters from ..helper.telegram_helper.message_utils import send_message -@handler_new_task +@new_task async def authorize(_, message): msg = message.text.split() thread_id = None @@ -49,7 +49,7 @@ async def authorize(_, message): await send_message(message, msg) -@handler_new_task +@new_task async def unauthorize(_, message): msg = message.text.split() thread_id = None @@ -81,7 +81,7 @@ async def unauthorize(_, message): await send_message(message, msg) -@handler_new_task +@new_task async def addSudo(_, message): id_ = "" msg = message.text.split() @@ -102,7 +102,7 @@ async def addSudo(_, message): await send_message(message, msg) -@handler_new_task +@new_task async def removeSudo(_, message): id_ = "" msg = message.text.split() diff --git a/bot/modules/bot_settings.py b/bot/modules/bot_settings.py index 01a1fdb24f5..ae972c7a031 100644 --- a/bot/modules/bot_settings.py +++ b/bot/modules/bot_settings.py @@ -43,8 +43,8 @@ from ..helper.ext_utils.bot_utils import ( SetInterval, sync_to_async, - handler_new_task, retry_function, + new_task, ) from ..helper.ext_utils.db_handler import database from ..helper.ext_utils.jdownloader_booter import jdownloader @@ -249,7 +249,7 @@ async def update_buttons(message, key=None, edit_type=None): await edit_message(message, msg, button) -@handler_new_task +@new_task async def edit_variable(_, message, pre_message, key): handler_dict[message.chat.id] = False value = message.text @@ -344,7 +344,7 @@ async def edit_variable(_, message, pre_message, key): await sabnzbd_client.set_special_config("servers", s) -@handler_new_task +@new_task async def edit_aria(_, message, pre_message, key): handler_dict[message.chat.id] = False value = message.text @@ -373,7 +373,7 @@ async def edit_aria(_, message, pre_message, key): await database.update_aria2(key, value) -@handler_new_task +@new_task async def edit_qbit(_, message, pre_message, key): handler_dict[message.chat.id] = False value = message.text @@ -393,7 +393,7 @@ async def edit_qbit(_, message, pre_message, key): await database.update_qbittorrent(key, value) -@handler_new_task +@new_task async def edit_nzb(_, message, pre_message, key): handler_dict[message.chat.id] = False value = message.text @@ -409,7 +409,7 @@ async def edit_nzb(_, message, pre_message, key): await database.update_nzb_config() -@handler_new_task +@new_task async def edit_nzb_server(_, message, pre_message, key, index=0): handler_dict[message.chat.id] = False value = message.text @@ -474,7 +474,7 @@ async def sync_jdownloader(): await database.update_private_file("cfg.zip") -@handler_new_task +@new_task async def update_private_file(_, message, pre_message): handler_dict[message.chat.id] = False if not message.media and (file_name := message.text): @@ -578,7 +578,7 @@ async def event_filter(_, __, event): client.remove_handler(*handler) -@handler_new_task +@new_task async def edit_bot_settings(client, query): data = query.data.split() message = query.message @@ -918,7 +918,7 @@ async def edit_bot_settings(client, query): await delete_message(message) -@handler_new_task +@new_task async def bot_settings(_, message): handler_dict[message.chat.id] = False msg, button = await get_buttons() diff --git a/bot/modules/cancel_task.py b/bot/modules/cancel_task.py index db4216dd02f..849d95a41b6 100644 --- a/bot/modules/cancel_task.py +++ b/bot/modules/cancel_task.py @@ -3,7 +3,7 @@ from pyrogram.handlers import MessageHandler, CallbackQueryHandler from bot import task_dict, bot, task_dict_lock, OWNER_ID, user_data, multi_tags -from ..helper.ext_utils.bot_utils import handler_new_task +from ..helper.ext_utils.bot_utils import new_task from ..helper.ext_utils.status_utils import ( get_task_by_gid, get_all_tasks, @@ -20,7 +20,7 @@ ) -@handler_new_task +@new_task async def cancel_task(_, message): user_id = message.from_user.id if message.from_user else message.sender_chat.id msg = message.text.split() @@ -58,7 +58,7 @@ async def cancel_task(_, message): await obj.cancel_task() -@handler_new_task +@new_task async def cancel_multi(_, query): data = query.data.split() user_id = query.from_user.id @@ -128,7 +128,7 @@ def create_cancel_buttons(is_sudo, user_id=""): return buttons.build_menu(2) -@handler_new_task +@new_task async def cancell_all_buttons(_, message): async with task_dict_lock: count = len(task_dict) @@ -141,7 +141,7 @@ async def cancell_all_buttons(_, message): await auto_delete_message(message, can_msg) -@handler_new_task +@new_task async def cancel_all_update(_, query): data = query.data.split() message = query.message diff --git a/bot/modules/exec.py b/bot/modules/exec.py index 297ea7dbfb2..6794ae1bb4d 100644 --- a/bot/modules/exec.py +++ b/bot/modules/exec.py @@ -8,7 +8,7 @@ from traceback import format_exc from bot import LOGGER, bot -from ..helper.ext_utils.bot_utils import sync_to_async, handler_new_task +from ..helper.ext_utils.bot_utils import sync_to_async, new_task from ..helper.telegram_helper.bot_commands import BotCommands from ..helper.telegram_helper.filters import CustomFilters from ..helper.telegram_helper.message_utils import send_file, send_message @@ -45,12 +45,12 @@ async def send(msg, message): await send_message(message, f"{msg}") -@handler_new_task +@new_task async def aioexecute(_, message): await send(await do("aexec", message), message) -@handler_new_task +@new_task async def execute(_, message): await send(await do("exec", message), message) @@ -108,7 +108,7 @@ async def do(func, message): return result -@handler_new_task +@new_task async def clear(_, message): log_input(message) global namespaces diff --git a/bot/modules/file_selector.py b/bot/modules/file_selector.py index 0c736b8cd98..4dff7dff292 100644 --- a/bot/modules/file_selector.py +++ b/bot/modules/file_selector.py @@ -17,7 +17,7 @@ from ..helper.ext_utils.bot_utils import ( bt_selection_buttons, sync_to_async, - handler_new_task, + new_task, ) from ..helper.ext_utils.status_utils import get_task_by_gid, MirrorStatus from ..helper.telegram_helper.bot_commands import BotCommands @@ -29,7 +29,7 @@ ) -@handler_new_task +@new_task async def select(_, message): if not config_dict["BASE_URL"]: await send_message(message, "Base URL not defined!") @@ -107,7 +107,7 @@ async def select(_, message): await send_message(message, msg, SBUTTONS) -@handler_new_task +@new_task async def get_confirm(_, query): user_id = query.from_user.id data = query.data.split() diff --git a/bot/modules/force_start.py b/bot/modules/force_start.py index 838de06b5d1..77d376eb9c6 100644 --- a/bot/modules/force_start.py +++ b/bot/modules/force_start.py @@ -11,7 +11,7 @@ queued_dl, queue_dict_lock, ) -from ..helper.ext_utils.bot_utils import handler_new_task +from ..helper.ext_utils.bot_utils import new_task from ..helper.ext_utils.status_utils import get_task_by_gid from ..helper.telegram_helper.bot_commands import BotCommands from ..helper.telegram_helper.filters import CustomFilters @@ -19,7 +19,7 @@ from ..helper.ext_utils.task_manager import start_dl_from_queued, start_up_from_queued -@handler_new_task +@new_task async def remove_from_queue(_, message): user_id = message.from_user.id if message.from_user else message.sender_chat.id msg = message.text.split() diff --git a/bot/modules/gd_count.py b/bot/modules/gd_count.py index 3a0e6934dd8..53e15400d43 100644 --- a/bot/modules/gd_count.py +++ b/bot/modules/gd_count.py @@ -2,7 +2,7 @@ from pyrogram.handlers import MessageHandler from bot import bot -from ..helper.ext_utils.bot_utils import sync_to_async, handler_new_task +from ..helper.ext_utils.bot_utils import sync_to_async, new_task from ..helper.ext_utils.links_utils import is_gdrive_link from ..helper.ext_utils.status_utils import get_readable_file_size from ..helper.mirror_leech_utils.gdrive_utils.count import GoogleDriveCount @@ -11,7 +11,7 @@ from ..helper.telegram_helper.message_utils import delete_message, send_message -@handler_new_task +@new_task async def countNode(_, message): args = message.text.split() user = message.from_user or message.sender_chat diff --git a/bot/modules/gd_delete.py b/bot/modules/gd_delete.py index 61129bae1c7..e34bae918ec 100644 --- a/bot/modules/gd_delete.py +++ b/bot/modules/gd_delete.py @@ -2,7 +2,7 @@ from pyrogram.handlers import MessageHandler from bot import bot, LOGGER -from ..helper.ext_utils.bot_utils import sync_to_async, handler_new_task +from ..helper.ext_utils.bot_utils import sync_to_async, new_task from ..helper.ext_utils.links_utils import is_gdrive_link from ..helper.mirror_leech_utils.gdrive_utils.delete import GoogleDriveDelete from ..helper.telegram_helper.bot_commands import BotCommands @@ -10,7 +10,7 @@ from ..helper.telegram_helper.message_utils import auto_delete_message, send_message -@handler_new_task +@new_task async def deletefile(_, message): args = message.text.split() user = message.from_user or message.sender_chat diff --git a/bot/modules/gd_search.py b/bot/modules/gd_search.py index 317f78aa6df..dbd240073af 100644 --- a/bot/modules/gd_search.py +++ b/bot/modules/gd_search.py @@ -5,7 +5,7 @@ from ..helper.ext_utils.bot_utils import ( sync_to_async, get_telegraph_list, - handler_new_task, + new_task, ) from ..helper.mirror_leech_utils.gdrive_utils.search import GoogleDriveSearch from ..helper.telegram_helper.bot_commands import BotCommands @@ -22,7 +22,9 @@ async def list_buttons(user_id, is_recursive=True, user_token=False): buttons.data_button( "Files", f"list_types {user_id} files {is_recursive} {user_token}" ) - buttons.data_button("Both", f"list_types {user_id} both {is_recursive} {user_token}") + buttons.data_button( + "Both", f"list_types {user_id} both {is_recursive} {user_token}" + ) buttons.data_button( f"Recursive: {is_recursive}", f"list_types {user_id} rec {is_recursive} {user_token}", @@ -61,7 +63,7 @@ async def _list_drive(key, message, item_type, is_recursive, user_token, user_id await edit_message(message, f"No result found for {key}") -@handler_new_task +@new_task async def select_type(_, query): user_id = query.from_user.id message = query.message @@ -90,7 +92,7 @@ async def select_type(_, query): await _list_drive(key, message, item_type, is_recursive, user_token, user_id) -@handler_new_task +@new_task async def gdrive_search(_, message): if len(message.text.split()) == 1: return await send_message(message, "Send a search key along with command") diff --git a/bot/modules/help.py b/bot/modules/help.py index 926557833ab..fcbf7da157b 100644 --- a/bot/modules/help.py +++ b/bot/modules/help.py @@ -2,7 +2,7 @@ from pyrogram.handlers import CallbackQueryHandler from bot import bot -from ..helper.ext_utils.bot_utils import COMMAND_USAGE, handler_new_task +from ..helper.ext_utils.bot_utils import COMMAND_USAGE, new_task from ..helper.ext_utils.help_messages import ( YT_HELP_DICT, MIRROR_HELP_DICT, @@ -12,7 +12,7 @@ from ..helper.telegram_helper.message_utils import edit_message, delete_message -@handler_new_task +@new_task async def arg_usage(_, query): data = query.data.split() message = query.message diff --git a/bot/modules/rss.py b/bot/modules/rss.py index 064d31ed410..a351c342642 100644 --- a/bot/modules/rss.py +++ b/bot/modules/rss.py @@ -10,7 +10,7 @@ from time import time from bot import scheduler, rss_dict, LOGGER, config_dict, bot -from ..helper.ext_utils.bot_utils import handler_new_task, arg_parser +from ..helper.ext_utils.bot_utils import new_task, arg_parser from ..helper.ext_utils.db_handler import database from ..helper.ext_utils.exceptions import RssShutdownException from ..helper.ext_utils.help_messages import RSS_HELP_MESSAGE @@ -60,13 +60,13 @@ async def update_rss_menu(query): await edit_message(query.message, msg, button) -@handler_new_task +@new_task async def get_rss_menu(_, message): msg, button = await rss_menu(message) await send_message(message, msg, button) -@handler_new_task +@new_task async def rss_sub(_, message, pre_event): user_id = message.from_user.id handler_dict[user_id] = False @@ -202,7 +202,7 @@ async def get_user_id(title): ) -@handler_new_task +@new_task async def rss_update(_, message, pre_event, state): user_id = message.from_user.id handler_dict[user_id] = False @@ -305,7 +305,7 @@ async def rss_list(query, start, all_users=False): await edit_message(query.message, list_feed, button) -@handler_new_task +@new_task async def rss_get(_, message, pre_event): user_id = message.from_user.id handler_dict[user_id] = False @@ -362,7 +362,7 @@ async def rss_get(_, message, pre_event): await update_rss_menu(pre_event) -@handler_new_task +@new_task async def rss_edit(_, message, pre_event): user_id = message.from_user.id handler_dict[user_id] = False @@ -416,7 +416,7 @@ async def rss_edit(_, message, pre_event): await update_rss_menu(pre_event) -@handler_new_task +@new_task async def rss_delete(_, message, pre_event): handler_dict[message.from_user.id] = False users = message.text.split() @@ -449,7 +449,7 @@ async def event_filter(_, __, event): client.remove_handler(*handler) -@handler_new_task +@new_task async def rss_listener(client, query): user_id = query.from_user.id message = query.message @@ -770,6 +770,7 @@ def add_job(): replace_existing=True, ) + add_job() scheduler.start() diff --git a/bot/modules/shell.py b/bot/modules/shell.py index 1967abf820f..a94af7fee73 100644 --- a/bot/modules/shell.py +++ b/bot/modules/shell.py @@ -3,13 +3,13 @@ from pyrogram.handlers import MessageHandler, EditedMessageHandler from bot import LOGGER, bot -from ..helper.ext_utils.bot_utils import cmd_exec, handler_new_task +from ..helper.ext_utils.bot_utils import cmd_exec, new_task from ..helper.telegram_helper.bot_commands import BotCommands from ..helper.telegram_helper.filters import CustomFilters from ..helper.telegram_helper.message_utils import send_message, send_file -@handler_new_task +@new_task async def shell(_, message): cmd = message.text.split(maxsplit=1) if len(cmd) == 1: diff --git a/bot/modules/status.py b/bot/modules/status.py index 6a249df9728..79b34ec192d 100644 --- a/bot/modules/status.py +++ b/bot/modules/status.py @@ -12,7 +12,7 @@ intervals, bot, ) -from ..helper.ext_utils.bot_utils import sync_to_async, handler_new_task +from ..helper.ext_utils.bot_utils import sync_to_async, new_task from ..helper.ext_utils.status_utils import ( MirrorStatus, get_readable_file_size, @@ -32,7 +32,7 @@ from ..helper.telegram_helper.button_build import ButtonMaker -@handler_new_task +@new_task async def mirror_status(_, message): async with task_dict_lock: count = len(task_dict) @@ -60,7 +60,7 @@ async def mirror_status(_, message): await delete_message(message) -@handler_new_task +@new_task async def status_pages(_, query): data = query.data.split() key = int(data[1]) diff --git a/bot/modules/torrent_search.py b/bot/modules/torrent_search.py index c5db0fcda37..3bbf0e73053 100644 --- a/bot/modules/torrent_search.py +++ b/bot/modules/torrent_search.py @@ -5,7 +5,7 @@ from urllib.parse import quote from bot import bot, LOGGER, config_dict, qbittorrent_client -from ..helper.ext_utils.bot_utils import sync_to_async, handler_new_task +from ..helper.ext_utils.bot_utils import sync_to_async, new_task from ..helper.ext_utils.status_utils import get_readable_file_size from ..helper.ext_utils.telegraph_helper import telegraph from ..helper.telegram_helper.bot_commands import BotCommands @@ -235,7 +235,7 @@ async def plugin_buttons(user_id): return buttons.build_menu(2) -@handler_new_task +@new_task async def torrent_search(_, message): user_id = message.from_user.id buttons = ButtonMaker() @@ -267,7 +267,7 @@ async def torrent_search(_, message): await send_message(message, "Choose site to search | Plugins:", button) -@handler_new_task +@new_task async def torrent_search_update(_, query): user_id = query.from_user.id message = query.message diff --git a/bot/modules/users_settings.py b/bot/modules/users_settings.py index 9c13f618d90..78c3517d5df 100644 --- a/bot/modules/users_settings.py +++ b/bot/modules/users_settings.py @@ -18,7 +18,7 @@ ) from ..helper.ext_utils.bot_utils import ( update_user_ldata, - handler_new_task, + new_task, get_size_bytes, ) from ..helper.ext_utils.db_handler import database @@ -206,7 +206,7 @@ async def update_user_settings(query): await edit_message(query.message, msg, button) -@handler_new_task +@new_task async def user_settings(_, message): from_user = message.from_user handler_dict[from_user.id] = False @@ -214,7 +214,7 @@ async def user_settings(_, message): await send_message(message, msg, button) -@handler_new_task +@new_task async def set_thumb(_, message, pre_event): user_id = message.from_user.id handler_dict[user_id] = False @@ -226,7 +226,7 @@ async def set_thumb(_, message, pre_event): await database.update_user_doc(user_id, "thumb", des_dir) -@handler_new_task +@new_task async def add_rclone(_, message, pre_event): user_id = message.from_user.id handler_dict[user_id] = False @@ -241,7 +241,7 @@ async def add_rclone(_, message, pre_event): await database.update_user_doc(user_id, "rclone_config", des_dir) -@handler_new_task +@new_task async def add_token_pickle(_, message, pre_event): user_id = message.from_user.id handler_dict[user_id] = False @@ -256,7 +256,7 @@ async def add_token_pickle(_, message, pre_event): await database.update_user_doc(user_id, "token_pickle", des_dir) -@handler_new_task +@new_task async def delete_path(_, message, pre_event): user_id = message.from_user.id handler_dict[user_id] = False @@ -273,7 +273,7 @@ async def delete_path(_, message, pre_event): await database.update_user_doc(user_id, "upload_paths", new_value) -@handler_new_task +@new_task async def set_option(_, message, pre_event, option): user_id = message.from_user.id handler_dict[user_id] = False @@ -340,7 +340,7 @@ async def event_filter(_, __, event): client.remove_handler(*handler) -@handler_new_task +@new_task async def edit_user_settings(client, query): from_user = query.from_user user_id = from_user.id @@ -853,7 +853,7 @@ async def edit_user_settings(client, query): await delete_message(message) -@handler_new_task +@new_task async def send_users_settings(_, message): if user_data: msg = "" diff --git a/bot/modules/ytdlp.py b/bot/modules/ytdlp.py index ec62ede5d53..16801034832 100644 --- a/bot/modules/ytdlp.py +++ b/bot/modules/ytdlp.py @@ -8,7 +8,7 @@ from bot import DOWNLOAD_DIR, bot, config_dict, LOGGER, bot_loop from ..helper.ext_utils.bot_utils import ( - handler_new_task, + new_task, sync_to_async, arg_parser, COMMAND_USAGE, @@ -27,7 +27,7 @@ ) -@handler_new_task +@new_task async def select_format(_, query, obj): data = query.data.split() message = query.message