Added language_code context
This commit is contained in:
@@ -5,12 +5,15 @@ from pyrogram import filters
|
||||
from pyrogram.types import ReplyKeyboardRemove, InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from pyrogram.enums.parse_mode import ParseMode
|
||||
from classes.holo_user import HoloUser
|
||||
from modules.utils import configGet, locale, logWrite
|
||||
from modules.utils import all_locales, configGet, locale, logWrite
|
||||
from modules.handlers.welcome import welcome_pass
|
||||
from modules.database import col_tmp
|
||||
|
||||
# Confirmation =================================================================================================================
|
||||
@app.on_message(~ filters.scheduled & filters.private & (filters.regex(locale("confirm", "keyboard")[0][0])))
|
||||
confirmation_1 = []
|
||||
for pattern in all_locales("confirm", "keyboard"):
|
||||
confirmation_1.append(pattern[0][0])
|
||||
@app.on_message(~ filters.scheduled & filters.private & filters.command(confirmation_1, prefixes=[""]))
|
||||
async def confirm_yes(app, msg):
|
||||
|
||||
holo_user = HoloUser(msg.from_user)
|
||||
@@ -81,7 +84,10 @@ async def confirm_yes(app, msg):
|
||||
# configSet(["sent"], True, file=str(holo_user.id))
|
||||
# configSet(["confirmed"], True, file=str(holo_user.id))
|
||||
|
||||
@app.on_message(~ filters.scheduled & filters.private & (filters.regex(locale("confirm", "keyboard")[1][0])))
|
||||
confirmation_2 = []
|
||||
for pattern in all_locales("confirm", "keyboard"):
|
||||
confirmation_2.append(pattern[1][0])
|
||||
@app.on_message(~ filters.scheduled & filters.private & filters.command(confirmation_2, prefixes=[""]))
|
||||
async def confirm_no(app, msg):
|
||||
|
||||
holo_user = HoloUser(msg.from_user)
|
||||
|
@@ -20,7 +20,7 @@ async def get_contact(app, msg):
|
||||
|
||||
if application is None:
|
||||
logWrite(f"User {holo_user.id} requested application of {msg.contact.user_id} but user does not exists")
|
||||
await msg.reply_text(locale("contact_invalid", "message"))
|
||||
await msg.reply_text(locale("contact_invalid", "message", locale=holo_user.locale))
|
||||
return
|
||||
|
||||
application_content = []
|
||||
@@ -30,24 +30,24 @@ async def get_contact(app, msg):
|
||||
|
||||
if i == 2:
|
||||
age = relativedelta(datetime.now(), application['application']['2'])
|
||||
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {application['application']['2'].strftime('%d.%m.%Y')} ({age.years} р.)")
|
||||
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles', locale=holo_user.locale)} {application['application']['2'].strftime('%d.%m.%Y')} ({age.years} р.)")
|
||||
elif i == 3:
|
||||
if application['application']['3']['countryCode'] == "UA":
|
||||
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {application['application']['3']['name']}")
|
||||
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles', locale=holo_user.locale)} {application['application']['3']['name']}")
|
||||
else:
|
||||
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {application['application']['3']['name']} ({application['application']['3']['adminName1']}, {application['application']['3']['countryName']})")
|
||||
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles', locale=holo_user.locale)} {application['application']['3']['name']} ({application['application']['3']['adminName1']}, {application['application']['3']['countryName']})")
|
||||
else:
|
||||
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {application['application'][question]}")
|
||||
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles', locale=holo_user.locale)} {application['application'][question]}")
|
||||
|
||||
i += 1
|
||||
|
||||
application_status = locale("application_status_accepted", "message").format((await app.get_users(application["admin"])).first_name, application["date"].strftime("%d.%m.%Y, %H:%M"))
|
||||
application_status = locale("application_status_accepted", "message", locale=holo_user.locale).format((await app.get_users(application["admin"])).first_name, application["date"].strftime("%d.%m.%Y, %H:%M"))
|
||||
|
||||
logWrite(f"User {holo_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))
|
||||
await msg.reply_text(locale("contact", "message", locale=holo_user.locale).format(str(msg.contact.user_id), "\n".join(application_content), application_status))
|
||||
|
||||
|
||||
else:
|
||||
logWrite(f"User {holo_user.id} requested application of someone but user is not telegram user")
|
||||
await msg.reply_text(locale("contact_not_member", "message"))
|
||||
await msg.reply_text(locale("contact_not_member", "message", locale=holo_user.locale))
|
||||
# ==============================================================================================================================
|
@@ -1,10 +1,15 @@
|
||||
from app import app
|
||||
from pyrogram import filters
|
||||
from pyrogram.types import ForceReply, ReplyKeyboardMarkup
|
||||
from modules.utils import locale, logWrite
|
||||
from modules.utils import all_locales, locale, logWrite
|
||||
|
||||
# Welcome check ================================================================================================================
|
||||
@app.on_message(~ filters.scheduled & filters.private & (filters.regex(locale("welcome", "keyboard")[0][0]) | filters.regex(locale("return", "keyboard")[0][0])))
|
||||
welcome_1 = []
|
||||
for pattern in all_locales("welcome", "keyboard"):
|
||||
welcome_1.append(pattern[0][0])
|
||||
for pattern in all_locales("return", "keyboard"):
|
||||
welcome_1.append(pattern[0][0])
|
||||
@app.on_message(~ filters.scheduled & filters.private & filters.command(welcome_1, prefixes=[""]))
|
||||
async def welcome_pass(app, msg, once_again: bool = True) -> None:
|
||||
"""Set user's stage to 1 and start a fresh application
|
||||
|
||||
@@ -18,13 +23,16 @@ 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")))
|
||||
await msg.reply_text(locale("question1", "message", locale=msg.from_user), reply_markup=ForceReply(placeholder=locale("question1", "force_reply", locale=msg.from_user)))
|
||||
# configSet(["stage"], 1, file=str(msg.from_user.id))
|
||||
# configSet(["sent"], False, file=str(msg.from_user.id))
|
||||
|
||||
@app.on_message(~ filters.scheduled & filters.private & (filters.regex(locale("welcome", "keyboard")[1][0])))
|
||||
welcome_2 = []
|
||||
for pattern in all_locales("welcome", "keyboard"):
|
||||
welcome_2.append(pattern[1][0])
|
||||
@app.on_message(~ filters.scheduled & filters.private & filters.command(welcome_2, prefixes=[""]))
|
||||
async def welcome_reject(app, msg):
|
||||
|
||||
logWrite(f"User {msg.from_user.id} rejected to start the application")
|
||||
await msg.reply_text(locale("goodbye", "message"), reply_markup=ReplyKeyboardMarkup(locale("return", "keyboard"), resize_keyboard=True))
|
||||
await msg.reply_text(locale("goodbye", "message", locale=msg.from_user), reply_markup=ReplyKeyboardMarkup(locale("return", "keyboard", locale=msg.from_user), resize_keyboard=True))
|
||||
# ==============================================================================================================================
|
Reference in New Issue
Block a user