Removed # type: ignore and fixed missing imports

This commit is contained in:
2022-12-06 10:26:22 +01:00
parent 712b5d22ab
commit 65f6b4e30e
19 changed files with 92 additions and 89 deletions

View File

@@ -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))

View File

@@ -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
]))
# ==============================================================================================================================

View File

@@ -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"),

View File

@@ -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))
# ==============================================================================================================================

View File

@@ -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))
# ==============================================================================================================================

View File

@@ -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))
# ==============================================================================================================================