From 65f6b4e30e81dbfc5a8f72e0a717727ef4d932f4 Mon Sep 17 00:00:00 2001 From: profitroll Date: Tue, 6 Dec 2022 10:26:22 +0100 Subject: [PATCH] Removed # type: ignore and fixed missing imports --- app.py | 2 +- main.py | 10 +++++----- modules/callbacks/nothing.py | 2 +- modules/callbacks/reapply.py | 22 +++++++++++----------- modules/callbacks/rules.py | 24 ++++++++++++------------ modules/callbacks/sub.py | 24 ++++++++++++------------ modules/callbacks/sus.py | 12 ++++++------ modules/commands/application.py | 10 +++++----- modules/commands/reapply.py | 16 ++++++++-------- modules/commands/rules.py | 4 ++-- modules/commands/start.py | 5 +++-- modules/commands/warn.py | 4 ++-- modules/commands/warnings.py | 8 ++++---- modules/commands_register.py | 10 +++++----- modules/handlers/confirmation.py | 5 +++-- modules/handlers/contact.py | 10 +++++----- modules/handlers/everything.py | 6 +++--- modules/handlers/welcome.py | 5 +++-- modules/utils.py | 2 +- 19 files changed, 92 insertions(+), 89 deletions(-) diff --git a/app.py b/app.py index f77475d..bd365a3 100644 --- a/app.py +++ b/app.py @@ -6,7 +6,7 @@ app = Client("holochecker", bot_token=configGet("bot_token", "bot"), api_id=conf async def isAnAdmin(admin_id): if admin_id == configGet("owner") or admin_id in configGet("admins"): return True - async for member in app.get_chat_members(configGet("admin_group")): # type: ignore + async for member in app.get_chat_members(configGet("admin_group")): if member.user.id == admin_id: return True return False \ No newline at end of file diff --git a/main.py b/main.py index 55a1f07..2e70cd9 100644 --- a/main.py +++ b/main.py @@ -8,7 +8,7 @@ from schedule import run_pending, every from app import app from modules.commands_register import commands_register -from pyrogram import idle # type: ignore +from pyrogram import idle pid = getpid() @@ -51,7 +51,7 @@ if __name__ == "__main__": # Yes, it should be in some kind of async main() function but I don't give a shit. # I did compare performance, almost no difference and it's much more useful this way. Change my mind. - app.start() # type: ignore + app.start() if configGet("birthdays_notify"): @@ -73,14 +73,14 @@ if __name__ == "__main__": t = Thread(target=background_task) t.start() - app.send_message(configGet("owner"), f"Starting up with pid `{pid}`") # type: ignore + app.send_message(configGet("owner"), f"Starting up with pid `{pid}`") commands_register(app) idle() - app.send_message(configGet("owner"), f"Shutting with pid `{pid}`") # type: ignore + app.send_message(configGet("owner"), f"Shutting with pid `{pid}`") - app.stop() # type: ignore + app.stop() killProc(pid) \ No newline at end of file diff --git a/modules/callbacks/nothing.py b/modules/callbacks/nothing.py index 65da562..f33eed0 100644 --- a/modules/callbacks/nothing.py +++ b/modules/callbacks/nothing.py @@ -3,7 +3,7 @@ from pyrogram import filters from modules.utils import locale # Callback empty =============================================================================================================== -@app.on_callback_query(filters.regex("nothing")) # type: ignore +@app.on_callback_query(filters.regex("nothing")) async def callback_query_nothing(app, clb): await clb.answer(text=locale("nothing", "callback")) # ============================================================================================================================== \ No newline at end of file diff --git a/modules/callbacks/reapply.py b/modules/callbacks/reapply.py index c961a66..facf257 100644 --- a/modules/callbacks/reapply.py +++ b/modules/callbacks/reapply.py @@ -8,12 +8,12 @@ from modules.handlers.confirmation import confirm_yes from modules.handlers.welcome import welcome_pass # Callbacks reapply ============================================================================================================ -@app.on_callback_query(filters.regex("reapply_yes_[\s\S]*")) # type: ignore +@app.on_callback_query(filters.regex("reapply_yes_[\s\S]*")) async def callback_reapply_query_accept(app, clb): fullclb = clb.data.split("_") - await app.send_message(configGet("admin_group"), locale("approved_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) # type: ignore + await app.send_message(configGet("admin_group"), locale("approved_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) logWrite(f"User {fullclb[2]} got their reapplication approved by {clb.from_user.id}") await app.send_message(int(fullclb[2]), locale("approved_joined", "message")) @@ -30,7 +30,7 @@ async def callback_reapply_query_accept(app, clb): edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]] await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)) - await clb.answer(text=locale("sub_accepted", "callback").format(fullclb[2]), show_alert=True) # type: ignore + await clb.answer(text=locale("sub_accepted", "callback").format(fullclb[2]), show_alert=True) need_link = True @@ -58,12 +58,12 @@ async def callback_reapply_query_accept(app, clb): else: await app.send_message(int(fullclb[2]), locale("approved_joined", "message")) -@app.on_callback_query(filters.regex("reapply_no_[\s\S]*")) # type: ignore +@app.on_callback_query(filters.regex("reapply_no_[\s\S]*")) async def callback_query_reapply_refuse(app, clb): fullclb = clb.data.split("_") - await app.send_message(configGet("admin_group"), locale("refused_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) # type: ignore + await app.send_message(configGet("admin_group"), locale("refused_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) await app.send_message(int(fullclb[2]), locale("refused", "message")) logWrite(f"User {fullclb[2]} got their reapplication refused by {clb.from_user.id}") @@ -79,20 +79,20 @@ async def callback_query_reapply_refuse(app, clb): edited_markup = [[InlineKeyboardButton(text=str(locale("declined", "button")), callback_data="nothing")]] await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)) - await clb.answer(text=locale("sub_refused", "callback").format(fullclb[2]), show_alert=True) # type: ignore + await clb.answer(text=locale("sub_refused", "callback").format(fullclb[2]), show_alert=True) # Use old application when user reapplies after leaving the chat -@app.on_callback_query(filters.regex("reapply_old_[\s\S]*")) # type: ignore +@app.on_callback_query(filters.regex("reapply_old_[\s\S]*")) async def callback_query_reapply_old(app, clb): fullclb = clb.data.split("_") message = await app.get_messages(clb.from_user.id, int(fullclb[2])) configSet(["approved"], False, file=str(clb.from_user.id)) configSet(["refused"], False, file=str(clb.from_user.id)) await confirm_yes(app, message) - await clb.message.edit(clb.message.text, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("done", "button"), "nothing")]])) # type: ignore + await clb.message.edit(clb.message.text, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("done", "button"), "nothing")]])) # Start a new application when user reapplies after leaving the chat -@app.on_callback_query(filters.regex("reapply_new_[\s\S]*")) # type: ignore +@app.on_callback_query(filters.regex("reapply_new_[\s\S]*")) async def callback_query_reapply_new(app, clb): fullclb = clb.data.split("_") @@ -106,10 +106,10 @@ async def callback_query_reapply_new(app, clb): message = await app.get_messages(clb.from_user.id, int(fullclb[2])) await welcome_pass(app, message, once_again=True) logWrite(f"User {clb.from_user.id} restarted the application after leaving the chat earlier") - await clb.message.edit(clb.message.text, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("done", "button"), "nothing")]])) # type: ignore + await clb.message.edit(clb.message.text, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("done", "button"), "nothing")]])) # Abort application fill in progress and restart it -@app.on_callback_query(filters.regex("reapply_stop_[\s\S]*")) # type: ignore +@app.on_callback_query(filters.regex("reapply_stop_[\s\S]*")) async def callback_query_reapply_stop(app, clb): fullclb = clb.data.split("_") diff --git a/modules/callbacks/rules.py b/modules/callbacks/rules.py index 7fe684f..ca91296 100644 --- a/modules/callbacks/rules.py +++ b/modules/callbacks/rules.py @@ -6,7 +6,7 @@ from modules.utils import locale, logWrite from modules.commands.rules import default_rules_markup # Callback rule ================================================================================================================ -@app.on_callback_query(filters.regex("rule_[\s\S]*")) # type: ignore +@app.on_callback_query(filters.regex("rule_[\s\S]*")) async def callback_query_rule(app, clb): fullclb = clb.data.split("_") @@ -17,24 +17,24 @@ async def callback_query_rule(app, clb): if rule_num == len(locale("rules")): lower_buttons = [ - InlineKeyboardButton(locale("rules_prev", "button"), callback_data=f"rule_{rule_num-1}") # type: ignore + InlineKeyboardButton(locale("rules_prev", "button"), callback_data=f"rule_{rule_num-1}") ] elif rule_num == 1: lower_buttons = [ - InlineKeyboardButton(locale("rules_next", "button"), callback_data=f"rule_{rule_num+1}") # type: ignore + InlineKeyboardButton(locale("rules_next", "button"), callback_data=f"rule_{rule_num+1}") ] else: lower_buttons = [ - InlineKeyboardButton(locale("rules_prev", "button"), callback_data=f"rule_{rule_num-1}"), # type: ignore - InlineKeyboardButton(locale("rules_next", "button"), callback_data=f"rule_{rule_num+1}") # type: ignore + InlineKeyboardButton(locale("rules_prev", "button"), callback_data=f"rule_{rule_num-1}"), + InlineKeyboardButton(locale("rules_next", "button"), callback_data=f"rule_{rule_num+1}") ] try: await clb.message.edit(text=locale("rules")[rule_num-1], disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup( [ [ - InlineKeyboardButton(locale("rules_home", "button"), callback_data="rules_home"), # type: ignore - InlineKeyboardButton(locale("rules_additional", "button"), callback_data="rules_additional") # type: ignore + InlineKeyboardButton(locale("rules_home", "button"), callback_data="rules_home"), + InlineKeyboardButton(locale("rules_additional", "button"), callback_data="rules_additional") ], lower_buttons ] @@ -43,9 +43,9 @@ async def callback_query_rule(app, clb): except bad_request_400.MessageNotModified: pass - await clb.answer(text=locale("rules_page", "callback").format(fullclb[1])) # type: ignore + await clb.answer(text=locale("rules_page", "callback").format(fullclb[1])) -@app.on_callback_query(filters.regex("rules_home")) # type: ignore +@app.on_callback_query(filters.regex("rules_home")) async def callback_query_rules_home(app, clb): logWrite(f"User {clb.from_user.id} requested to check out homepage rules") @@ -55,9 +55,9 @@ async def callback_query_rules_home(app, clb): except bad_request_400.MessageNotModified: pass - await clb.answer(text=locale("rules_home", "callback")) # type: ignore + await clb.answer(text=locale("rules_home", "callback")) -@app.on_callback_query(filters.regex("rules_additional")) # type: ignore +@app.on_callback_query(filters.regex("rules_additional")) async def callback_query_rules_additional(app, clb): logWrite(f"User {clb.from_user.id} requested to check out additional rules") @@ -67,5 +67,5 @@ async def callback_query_rules_additional(app, clb): except bad_request_400.MessageNotModified: pass - await clb.answer(text=locale("rules_additional", "callback")) # type: ignore + await clb.answer(text=locale("rules_additional", "callback")) # ============================================================================================================================== \ No newline at end of file diff --git a/modules/callbacks/sub.py b/modules/callbacks/sub.py index 19a774e..c21d7d1 100644 --- a/modules/callbacks/sub.py +++ b/modules/callbacks/sub.py @@ -6,12 +6,12 @@ from pyrogram import filters from modules.utils import configGet, configSet, jsonLoad, jsonSave, locale, logWrite # Callbacks application ======================================================================================================== -@app.on_callback_query(filters.regex("sub_yes_[\s\S]*")) # type: ignore +@app.on_callback_query(filters.regex("sub_yes_[\s\S]*")) async def callback_query_accept(app, clb): fullclb = clb.data.split("_") - await app.send_message(configGet("admin_group"), locale("approved_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) # type: ignore + await app.send_message(configGet("admin_group"), locale("approved_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) logWrite(f"User {fullclb[2]} got approved by {clb.from_user.id}") need_link = True @@ -52,14 +52,14 @@ async def callback_query_accept(app, clb): edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]] await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)) - await clb.answer(text=locale("sub_accepted", "callback").format(fullclb[2]), show_alert=True) # type: ignore + await clb.answer(text=locale("sub_accepted", "callback").format(fullclb[2]), show_alert=True) -@app.on_callback_query(filters.regex("sub_no_aggressive_[\s\S]*")) # type: ignore +@app.on_callback_query(filters.regex("sub_no_aggressive_[\s\S]*")) async def callback_query_refuse_aggressive(app, clb): fullclb = clb.data.split("_") - await app.send_message(configGet("admin_group"), locale("refused_by_agr", "message").format(clb.from_user.first_name, fullclb[3]), disable_notification=True) # type: ignore + await app.send_message(configGet("admin_group"), locale("refused_by_agr", "message").format(clb.from_user.first_name, fullclb[3]), disable_notification=True) await app.send_message(int(fullclb[3]), locale("refused", "message")) logWrite(f"User {fullclb[3]} got refused by {clb.from_user.id} due to being aggressive") @@ -75,14 +75,14 @@ async def callback_query_refuse_aggressive(app, clb): edited_markup = [[InlineKeyboardButton(text=str(locale("declined", "button")), callback_data="nothing")]] await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)) - await clb.answer(text=locale("sub_no_aggressive", "callback").format(fullclb[3]), show_alert=True) # type: ignore + await clb.answer(text=locale("sub_no_aggressive", "callback").format(fullclb[3]), show_alert=True) -@app.on_callback_query(filters.regex("sub_no_russian_[\s\S]*")) # type: ignore +@app.on_callback_query(filters.regex("sub_no_russian_[\s\S]*")) async def callback_query_refuse_russian(app, clb): fullclb = clb.data.split("_") - await app.send_message(configGet("admin_group"), locale("refused_by_rus", "message").format(clb.from_user.first_name, fullclb[3]), disable_notification=True) # type: ignore + await app.send_message(configGet("admin_group"), locale("refused_by_rus", "message").format(clb.from_user.first_name, fullclb[3]), disable_notification=True) await app.send_message(int(fullclb[3]), locale("refused", "message")) await app.send_message(int(fullclb[3]), locale("refused_russian", "message")) logWrite(f"User {fullclb[3]} got refused by {clb.from_user.id} due to being russian") @@ -99,14 +99,14 @@ async def callback_query_refuse_russian(app, clb): edited_markup = [[InlineKeyboardButton(text=str(locale("declined", "button")), callback_data="nothing")]] await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)) - await clb.answer(text=locale("sub_no_russian", "callback").format(fullclb[3]), show_alert=True) # type: ignore + await clb.answer(text=locale("sub_no_russian", "callback").format(fullclb[3]), show_alert=True) -@app.on_callback_query(filters.regex("sub_no_[\s\S]*")) # type: ignore +@app.on_callback_query(filters.regex("sub_no_[\s\S]*")) async def callback_query_refuse(app, clb): fullclb = clb.data.split("_") - await app.send_message(configGet("admin_group"), locale("refused_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) # type: ignore + await app.send_message(configGet("admin_group"), locale("refused_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) await app.send_message(int(fullclb[2]), locale("refused", "message")) logWrite(f"User {fullclb[2]} got refused by {clb.from_user.id}") @@ -122,5 +122,5 @@ async def callback_query_refuse(app, clb): edited_markup = [[InlineKeyboardButton(text=str(locale("declined", "button")), callback_data="nothing")]] await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)) - await clb.answer(text=locale("sub_refused", "callback").format(fullclb[2]), show_alert=True) # type: ignore + await clb.answer(text=locale("sub_refused", "callback").format(fullclb[2]), show_alert=True) # ============================================================================================================================== \ No newline at end of file diff --git a/modules/callbacks/sus.py b/modules/callbacks/sus.py index fd53fa1..62931b3 100644 --- a/modules/callbacks/sus.py +++ b/modules/callbacks/sus.py @@ -5,18 +5,18 @@ from pyrogram import filters from modules.utils import configGet, configSet, jsonLoad, jsonSave, locale, logWrite # Callbacks sus users ========================================================================================================== -@app.on_callback_query(filters.regex("sus_allow_[\s\S]*")) # type: ignore +@app.on_callback_query(filters.regex("sus_allow_[\s\S]*")) async def callback_query_sus_allow(app, clb): fullclb = clb.data.split("_") - await app.send_message(configGet("admin_group"), locale("sus_allowed_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) # type: ignore + await app.send_message(configGet("admin_group"), locale("sus_allowed_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) logWrite(f"User {fullclb[2]} was allowed to join with another link by {clb.from_user.id}") edited_markup = [[InlineKeyboardButton(text=str(locale("sus_allowed", "button")), callback_data="nothing")]] await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)) - await clb.answer(text=locale("sus_allowed", "callback").format(fullclb[2]), show_alert=True) # type: ignore + await clb.answer(text=locale("sus_allowed", "callback").format(fullclb[2]), show_alert=True) await app.restrict_chat_member(configGet("destination_group"), int(fullclb[2]), permissions=ChatPermissions( can_send_messages=True, @@ -26,18 +26,18 @@ async def callback_query_sus_allow(app, clb): ) ) -@app.on_callback_query(filters.regex("sus_refuse_[\s\S]*")) # type: ignore +@app.on_callback_query(filters.regex("sus_refuse_[\s\S]*")) async def callback_query_sus_refuse(app, clb): fullclb = clb.data.split("_") - await app.send_message(configGet("admin_group"), locale("sus_refused_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) # type: ignore + await app.send_message(configGet("admin_group"), locale("sus_refused_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) logWrite(f"User {fullclb[2]} was refused to join with another link by {clb.from_user.id}") edited_markup = [[InlineKeyboardButton(text=str(locale("sus_refused", "button")), callback_data="nothing")]] await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)) - await clb.answer(text=locale("sus_refused", "callback").format(fullclb[2]), show_alert=True) # type: ignore + await clb.answer(text=locale("sus_refused", "callback").format(fullclb[2]), show_alert=True) await app.ban_chat_member(configGet("destination_group"), int(fullclb[2])) diff --git a/modules/commands/application.py b/modules/commands/application.py index 0777de4..5bf3186 100644 --- a/modules/commands/application.py +++ b/modules/commands/application.py @@ -33,20 +33,20 @@ async def cmd_application(app, msg): i += 1 if user_data["sent"]: if user_data["approved"]: - application_status = locale("application_status_accepted", "message").format((await app.get_users(application["approved_by"])).first_name, datetime.fromtimestamp(application["approval_date"]).strftime("%d.%m.%Y, %H:%M")) # type: ignore + application_status = locale("application_status_accepted", "message").format((await app.get_users(application["approved_by"])).first_name, datetime.fromtimestamp(application["approval_date"]).strftime("%d.%m.%Y, %H:%M")) elif application["refused"]: - application_status = locale("application_status_refused", "message").format((await app.get_users(application["refused_by"])).first_name, datetime.fromtimestamp(application["refusal_date"]).strftime("%d.%m.%Y, %H:%M")) # type: ignore + application_status = locale("application_status_refused", "message").format((await app.get_users(application["refused_by"])).first_name, datetime.fromtimestamp(application["refusal_date"]).strftime("%d.%m.%Y, %H:%M")) else: application_status = locale("application_status_on_hold", "message") else: if user_data["approved"]: - application_status = locale("application_status_accepted", "message").format((await app.get_users(application["approved_by"])).first_name, datetime.fromtimestamp(application["approval_date"]).strftime("%d.%m.%Y, %H:%M")) # type: ignore + application_status = locale("application_status_accepted", "message").format((await app.get_users(application["approved_by"])).first_name, datetime.fromtimestamp(application["approval_date"]).strftime("%d.%m.%Y, %H:%M")) elif application["refused"]: - application_status = locale("application_status_refused", "message").format((await app.get_users(application["refused_by"])).first_name, datetime.fromtimestamp(application["refusal_date"]).strftime("%d.%m.%Y, %H:%M")) # type: ignore + application_status = locale("application_status_refused", "message").format((await app.get_users(application["refused_by"])).first_name, datetime.fromtimestamp(application["refusal_date"]).strftime("%d.%m.%Y, %H:%M")) else: application_status = locale("application_status_not_send", "message") logWrite(f"User {msg.from_user.id} requested application of {user_id}") - await msg.reply_text(locale("contact", "message").format(str(user_id), "\n".join(application_content), application_status), quote=should_quote(msg)) # type: ignore + await msg.reply_text(locale("contact", "message").format(str(user_id), "\n".join(application_content), application_status), quote=should_quote(msg)) except FileNotFoundError: logWrite(f"User {msg.from_user.id} requested application of {user_id} but user does not exists") await msg.reply_text(locale("contact_invalid", "message"), quote=should_quote(msg)) diff --git a/modules/commands/reapply.py b/modules/commands/reapply.py index d628e40..b17fa4c 100644 --- a/modules/commands/reapply.py +++ b/modules/commands/reapply.py @@ -21,25 +21,25 @@ async def cmd_reapply(app, msg): else: await msg.reply_text(locale("reapply_left_chat", "message"), reply_markup=InlineKeyboardMarkup([ [ - InlineKeyboardButton(locale("reapply_old_one", "button"), f"reapply_old_{msg.id}") # type: ignore + InlineKeyboardButton(locale("reapply_old_one", "button"), f"reapply_old_{msg.id}") ], [ - InlineKeyboardButton(locale("reapply_new_one", "button"), f"reapply_new_{msg.id}") # type: ignore + InlineKeyboardButton(locale("reapply_new_one", "button"), f"reapply_new_{msg.id}") ] ])) else: - await msg.reply_text(locale("reapply_in_progress", "message").format(locale("confirm", "keyboard")[1][0]), reply_markup=InlineKeyboardMarkup([ # type: ignore + await msg.reply_text(locale("reapply_in_progress", "message").format(locale("confirm", "keyboard")[1][0]), reply_markup=InlineKeyboardMarkup([ [ - InlineKeyboardButton(locale("applying_stop", "button"), f"reapply_stop_{msg.id}") # type: ignore + InlineKeyboardButton(locale("applying_stop", "button"), f"reapply_stop_{msg.id}") ] - ])) # type: ignore + ])) else: if configGet("sent", file=str(msg.from_user.id)): await msg.reply_text(locale("reapply_forbidden", "message")) else: - await msg.reply_text(locale("reapply_in_progress", "message").format(locale("confirm", "keyboard")[1][0]), reply_markup=InlineKeyboardMarkup([ # type: ignore + await msg.reply_text(locale("reapply_in_progress", "message").format(locale("confirm", "keyboard")[1][0]), reply_markup=InlineKeyboardMarkup([ [ - InlineKeyboardButton(locale("applying_stop", "button"), f"reapply_stop_{msg.id}") # type: ignore + InlineKeyboardButton(locale("applying_stop", "button"), f"reapply_stop_{msg.id}") ] - ])) # type: ignore + ])) # ============================================================================================================================== \ No newline at end of file diff --git a/modules/commands/rules.py b/modules/commands/rules.py index fe7c3a6..f4cfe37 100644 --- a/modules/commands/rules.py +++ b/modules/commands/rules.py @@ -7,8 +7,8 @@ from modules.utils import locale default_rules_markup = InlineKeyboardMarkup( [ [ - InlineKeyboardButton(locale("rules_home", "button"), callback_data="rules_home"), # type: ignore - InlineKeyboardButton(locale("rules_additional", "button"), callback_data="rules_additional") # type: ignore + InlineKeyboardButton(locale("rules_home", "button"), callback_data="rules_home"), + InlineKeyboardButton(locale("rules_additional", "button"), callback_data="rules_additional") ], [ InlineKeyboardButton("1", callback_data="rule_1"), diff --git a/modules/commands/start.py b/modules/commands/start.py index 35e771e..42c4cf2 100644 --- a/modules/commands/start.py +++ b/modules/commands/start.py @@ -1,7 +1,8 @@ from app import app from os import sep from pyrogram import filters -from modules.utils import jsonLoad, jsonSave, configGet, configSet, logWrite +from pyrogram.types import ReplyKeyboardMarkup +from modules.utils import jsonLoad, jsonSave, configGet, configSet, locale, logWrite # Start command ================================================================================================================ @app.on_message(~ filters.scheduled & filters.private & filters.command(["start"], prefixes=["/"])) @@ -20,5 +21,5 @@ async def cmd_start(app, msg): configSet(["telegram_locale"], str(msg.from_user.language_code), file=str(msg.from_user.id)) logWrite(f"User {msg.from_user.id} started bot interaction") - await msg.reply_text(locale("start", "message"), reply_markup=ReplyKeyboardMarkup(locale("welcome", "keyboard"), resize_keyboard=True)) # type: ignore + await msg.reply_text(locale("start", "message"), reply_markup=ReplyKeyboardMarkup(locale("welcome", "keyboard"), resize_keyboard=True)) # ============================================================================================================================== \ No newline at end of file diff --git a/modules/commands/warn.py b/modules/commands/warn.py index 3dde539..3a8419d 100644 --- a/modules/commands/warn.py +++ b/modules/commands/warn.py @@ -1,7 +1,7 @@ from os import sep from app import app, isAnAdmin from pyrogram import filters -from modules.utils import jsonLoad, jsonSave, configGet +from modules.utils import jsonLoad, jsonSave, configGet, locale # Warn command ================================================================================================================= @app.on_message(~ filters.scheduled & filters.command(["warn"], prefixes=["/"])) @@ -16,5 +16,5 @@ async def cmd_warn(app, msg): else: warnings[str(msg.reply_to_message.from_user.id)] += 1 jsonSave(warnings, f"{configGet('data', 'locations')}{sep}warnings.json") - await msg.reply_text(locale("warned", "message").format(msg.reply_to_message.from_user.first_name, msg.reply_to_message.from_user.id)) # type: ignore + await msg.reply_text(locale("warned", "message").format(msg.reply_to_message.from_user.first_name, msg.reply_to_message.from_user.id)) # ============================================================================================================================== \ No newline at end of file diff --git a/modules/commands/warnings.py b/modules/commands/warnings.py index cef03bf..d88b99b 100644 --- a/modules/commands/warnings.py +++ b/modules/commands/warnings.py @@ -28,14 +28,14 @@ async def cmd_warnings(app, msg): target_name = target.first_name target_id = str(target.id) else: - await msg.reply_text(locale("no_user_warnings", "message").format(msg.command[1])) # type: ignore + await msg.reply_text(locale("no_user_warnings", "message").format(msg.command[1])) return if target_id not in warnings: - await msg.reply_text(locale("no_warnings", "message").format(target_name, target_id), quote=should_quote(msg)) # type: ignore + await msg.reply_text(locale("no_warnings", "message").format(target_name, target_id), quote=should_quote(msg)) else: if warnings[target_id] <= 5: - await msg.reply_text(locale("warnings_1", "message").format(target_name, target_id, warnings[target_id]), quote=should_quote(msg)) # type: ignore + await msg.reply_text(locale("warnings_1", "message").format(target_name, target_id, warnings[target_id]), quote=should_quote(msg)) else: - await msg.reply_text(locale("warnings_2", "message").format(target_name, target_id, warnings[target_id]), quote=should_quote(msg)) # type: ignore + await msg.reply_text(locale("warnings_2", "message").format(target_name, target_id, warnings[target_id]), quote=should_quote(msg)) # ============================================================================================================================== \ No newline at end of file diff --git a/modules/commands_register.py b/modules/commands_register.py index ac54106..44b87a5 100644 --- a/modules/commands_register.py +++ b/modules/commands_register.py @@ -8,7 +8,7 @@ def commands_register(app): commands_list = [] for command in configGet("commands"): commands_list.append(BotCommand(command, configGet("commands")[command])) - app.set_bot_commands(commands_list) # type: ignore + app.set_bot_commands(commands_list) # Registering admin commands commands_admin_list = [] @@ -20,20 +20,20 @@ def commands_register(app): for admin in configGet("admins"): try: - app.set_bot_commands(commands_admin_list, scope=BotCommandScopeChat(chat_id=admin)) # type: ignore + app.set_bot_commands(commands_admin_list, scope=BotCommandScopeChat(chat_id=admin)) except bad_request_400.PeerIdInvalid: pass - app.set_bot_commands(commands_admin_list, scope=BotCommandScopeChat(chat_id=configGet("owner"))) # type: ignore + app.set_bot_commands(commands_admin_list, scope=BotCommandScopeChat(chat_id=configGet("owner"))) # Registering admin group commands commands_group_admin_list = [] for command in configGet("commands_group_admin"): commands_group_admin_list.append(BotCommand(command, configGet("commands_group_admin")[command])) - app.set_bot_commands(commands_group_admin_list, scope=BotCommandScopeChat(chat_id=configGet("admin_group"))) # type: ignore + app.set_bot_commands(commands_group_admin_list, scope=BotCommandScopeChat(chat_id=configGet("admin_group"))) # Registering destination group commands commands_group_destination_list = [] for command in configGet("commands_group_destination"): commands_group_destination_list.append(BotCommand(command, configGet("commands_group_destination")[command])) - app.set_bot_commands(commands_group_destination_list, scope=BotCommandScopeChat(chat_id=configGet("destination_group"))) # type: ignore \ No newline at end of file + app.set_bot_commands(commands_group_destination_list, scope=BotCommandScopeChat(chat_id=configGet("destination_group"))) \ No newline at end of file diff --git a/modules/handlers/confirmation.py b/modules/handlers/confirmation.py index 599a60f..95620f4 100644 --- a/modules/handlers/confirmation.py +++ b/modules/handlers/confirmation.py @@ -5,6 +5,7 @@ from datetime import datetime from app import app from pyrogram import filters from pyrogram.types import ReplyKeyboardRemove, InlineKeyboardMarkup, InlineKeyboardButton +from pyrogram.enums.parse_mode import ParseMode from modules.utils import configGet, configSet, jsonLoad, jsonSave, locale, logWrite from modules.handlers.welcome import welcome_pass @@ -47,7 +48,7 @@ async def confirm_yes(app, msg): i += 1 if configGet("reapply", file=str(msg.from_user.id)): - await app.send_message(chat_id=configGet("admin_group"), text=(locale("reapply_got", "message")).format(str(msg.from_user.id), msg.from_user.first_name, msg.from_user.last_name, msg.from_user.username, "\n".join(application_content)), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup( # type: ignore + await app.send_message(chat_id=configGet("admin_group"), text=(locale("reapply_got", "message")).format(str(msg.from_user.id), msg.from_user.first_name, msg.from_user.last_name, msg.from_user.username, "\n".join(application_content)), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton(text=str(locale("reapply_yes", "button")), callback_data=f"reapply_yes_{msg.from_user.id}") @@ -59,7 +60,7 @@ async def confirm_yes(app, msg): ) ) else: - await app.send_message(chat_id=configGet("admin_group"), text=(locale("application_got", "message")).format(str(msg.from_user.id), msg.from_user.first_name, msg.from_user.last_name, msg.from_user.username, "\n".join(application_content)), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup( # type: ignore + await app.send_message(chat_id=configGet("admin_group"), text=(locale("application_got", "message")).format(str(msg.from_user.id), msg.from_user.first_name, msg.from_user.last_name, msg.from_user.username, "\n".join(application_content)), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton(text=str(locale("sub_yes", "button")), callback_data=f"sub_yes_{msg.from_user.id}") diff --git a/modules/handlers/contact.py b/modules/handlers/contact.py index 051599c..6a8f5a7 100644 --- a/modules/handlers/contact.py +++ b/modules/handlers/contact.py @@ -24,20 +24,20 @@ async def get_contact(app, msg): i += 1 if user_data["sent"]: if user_data["approved"]: - application_status = locale("application_status_accepted", "message").format((await app.get_users(application["approved_by"])).first_name, datetime.fromtimestamp(application["approval_date"]).strftime("%d.%m.%Y, %H:%M")) # type: ignore + application_status = locale("application_status_accepted", "message").format((await app.get_users(application["approved_by"])).first_name, datetime.fromtimestamp(application["approval_date"]).strftime("%d.%m.%Y, %H:%M")) elif application["refused"]: - application_status = locale("application_status_refused", "message").format((await app.get_users(application["refused_by"])).first_name, datetime.fromtimestamp(application["refusal_date"]).strftime("%d.%m.%Y, %H:%M")) # type: ignore + application_status = locale("application_status_refused", "message").format((await app.get_users(application["refused_by"])).first_name, datetime.fromtimestamp(application["refusal_date"]).strftime("%d.%m.%Y, %H:%M")) else: application_status = locale("application_status_on_hold", "message") else: if user_data["approved"]: - application_status = locale("application_status_accepted", "message").format((await app.get_users(application["approved_by"])).first_name, datetime.fromtimestamp(application["approval_date"]).strftime("%d.%m.%Y, %H:%M")) # type: ignore + application_status = locale("application_status_accepted", "message").format((await app.get_users(application["approved_by"])).first_name, datetime.fromtimestamp(application["approval_date"]).strftime("%d.%m.%Y, %H:%M")) elif application["refused"]: - application_status = locale("application_status_refused", "message").format((await app.get_users(application["refused_by"])).first_name, datetime.fromtimestamp(application["refusal_date"]).strftime("%d.%m.%Y, %H:%M")) # type: ignore + application_status = locale("application_status_refused", "message").format((await app.get_users(application["refused_by"])).first_name, datetime.fromtimestamp(application["refusal_date"]).strftime("%d.%m.%Y, %H:%M")) else: application_status = locale("application_status_not_send", "message") logWrite(f"User {msg.from_user.id} requested application of {msg.contact.user_id}") - await msg.reply_text(locale("contact", "message").format(str(msg.contact.user_id), "\n".join(application_content), application_status)) # type: ignore + await msg.reply_text(locale("contact", "message").format(str(msg.contact.user_id), "\n".join(application_content), application_status)) except FileNotFoundError: logWrite(f"User {msg.from_user.id} requested application of {msg.contact.user_id} but user does not exists") await msg.reply_text(locale("contact_invalid", "message")) diff --git a/modules/handlers/everything.py b/modules/handlers/everything.py index a06b070..6547321 100644 --- a/modules/handlers/everything.py +++ b/modules/handlers/everything.py @@ -2,7 +2,7 @@ from datetime import datetime from app import app import asyncio from pyrogram import filters -from pyrogram.types import ForceReply +from pyrogram.types import ForceReply, ReplyKeyboardMarkup from modules.utils import configGet, configSet, locale, logWrite # Any other input ============================================================================================================== @@ -33,7 +33,7 @@ async def any_stage(app, msg): elif ((datetime.now() - input_dt).days) < ((datetime.now() - datetime.now().replace(year=datetime.now().year - configGet("age_allowed"))).days): logWrite(f"User {msg.from_user.id} failed stage {user_stage} due to being underage") - await msg.reply_text(locale("question2_underage", "message").format(str(configGet("age_allowed"))), reply_markup=ForceReply(placeholder=str(locale("question2", "force_reply")))) # type: ignore + await msg.reply_text(locale("question2_underage", "message").format(str(configGet("age_allowed"))), reply_markup=ForceReply(placeholder=str(locale("question2", "force_reply")))) else: logWrite(f"User {msg.from_user.id} completed stage {user_stage} of application") @@ -59,7 +59,7 @@ async def any_stage(app, msg): for question in configGet("application", file=str(msg.from_user.id)): application_content.append(f"{locale('question'+str(i), 'message', 'question_titles')} {configGet('application', file=str(msg.from_user.id))[question]}") i += 1 - await msg.reply_text(locale("confirm", "message").format("\n".join(application_content)), reply_markup=ReplyKeyboardMarkup(locale("confirm", "keyboard"), resize_keyboard=True)) # type: ignore + await msg.reply_text(locale("confirm", "message").format("\n".join(application_content)), reply_markup=ReplyKeyboardMarkup(locale("confirm", "keyboard"), resize_keyboard=True)) #configSet("sent", True, file=str(msg.from_user.id)) #configSet("application_date", int(time()), file=str(msg.from_user.id)) else: diff --git a/modules/handlers/welcome.py b/modules/handlers/welcome.py index c000e3a..6c5f5fc 100644 --- a/modules/handlers/welcome.py +++ b/modules/handlers/welcome.py @@ -1,5 +1,6 @@ from app import app from pyrogram import filters +from pyrogram.types import ForceReply, ReplyKeyboardMarkup from modules.utils import configGet, configSet, locale, logWrite # Welcome check ================================================================================================================ @@ -17,7 +18,7 @@ async def welcome_pass(app, msg, once_again: bool = True) -> None: await msg.reply_text(locale("privacy_notice", "message")) logWrite(f"User {msg.from_user.id} confirmed starting the application") - await msg.reply_text(locale("question1", "message"), reply_markup=ForceReply(placeholder=locale("question1", "force_reply"))) # type: ignore + await msg.reply_text(locale("question1", "message"), reply_markup=ForceReply(placeholder=locale("question1", "force_reply"))) configSet(["stage"], 1, file=str(msg.from_user.id)) configSet(["sent"], False, file=str(msg.from_user.id)) @@ -25,5 +26,5 @@ async def welcome_pass(app, msg, once_again: bool = True) -> None: async def welcome_reject(app, msg): logWrite(f"User {msg.from_user.id} refused to start the application") - await msg.reply_text(locale("goodbye", "message"), reply_markup=ReplyKeyboardMarkup(locale("return", "keyboard"), resize_keyboard=True)) # type: ignore + await msg.reply_text(locale("goodbye", "message"), reply_markup=ReplyKeyboardMarkup(locale("return", "keyboard"), resize_keyboard=True)) # ============================================================================================================================== \ No newline at end of file diff --git a/modules/utils.py b/modules/utils.py index be7f4fd..cebdded 100644 --- a/modules/utils.py +++ b/modules/utils.py @@ -137,7 +137,7 @@ except ModuleNotFoundError: def killProc(pid): if osname == "posix": - from signal import SIGKILL # type: ignore + from signal import SIGKILL kill(pid, SIGKILL) else: p = Process(pid)