Application options for returning users [Done]

This commit is contained in:
Profitroll 2022-12-05 15:25:07 +01:00
parent 1c0c8fa8c4
commit 22a2224af1
2 changed files with 24 additions and 7 deletions

View File

@ -125,7 +125,8 @@
"rules_additional": " Додаткові",
"rules_next": "Далі ➡️",
"rules_prev": "⬅️ Назад",
"applying_stop": "🛑 Перервати заповнення"
"applying_stop": "🛑 Перервати заповнення",
"done": "✅ Готово"
},
"callback": {
"sub_accepted": "✅ Анкету {0} схвалено",

28
main.py
View File

@ -254,10 +254,10 @@ 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.from_user.id}")
InlineKeyboardButton(locale("reapply_old_one", "button"), f"reapply_old_{msg.id}")
],
[
InlineKeyboardButton(locale("reapply_new_one", "button"), f"reapply_new_{msg.from_user.id}")
InlineKeyboardButton(locale("reapply_new_one", "button"), f"reapply_new_{msg.id}")
]
]))
else:
@ -594,12 +594,29 @@ async def callback_query_reapply_refuse(app, clb):
# Use old application when user reapplies after leaving the chat
@app.on_callback_query(filters.regex("reapply_old_[\s\S]*")) # type: ignore
async def callback_query_reapply_old(app, clb):
pass
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")]]))
# Start a new application when user reapplies after leaving the chat
@app.on_callback_query(filters.regex("reapply_new_[\s\S]*")) # type: ignore
async def callback_query_reapply_new(app, clb):
pass
fullclb = clb.data.split("_")
jsonSave(jsonLoad(f"{configGet('data', 'locations')}{sep}user_default.json"), f"{configGet('data', 'locations')}{sep}users{sep}{clb.from_user.id}.json")
configSet(["telegram_id"], str(clb.from_user.username), file=str(clb.from_user.id))
configSet(["telegram_name"], f"{clb.from_user.first_name} {clb.from_user.last_name}", file=str(clb.from_user.id))
configSet(["telegram_phone"], str(clb.from_user.phone_number), file=str(clb.from_user.id))
configSet(["telegram_locale"], str(clb.from_user.language_code), file=str(clb.from_user.id))
await clb.answer(locale("reapply_stopped", "callback"))
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")]]))
# Abort application fill in progress and restart it
@app.on_callback_query(filters.regex("reapply_stop_[\s\S]*")) # type: ignore
@ -607,8 +624,6 @@ async def callback_query_reapply_stop(app, clb):
fullclb = clb.data.split("_")
user_stage = configGet("stage", file=str(clb.from_user.id))
jsonSave(jsonLoad(f"{configGet('data', 'locations')}{sep}user_default.json"), f"{configGet('data', 'locations')}{sep}users{sep}{clb.from_user.id}.json")
configSet(["telegram_id"], str(clb.from_user.username), file=str(clb.from_user.id))
configSet(["telegram_name"], f"{clb.from_user.first_name} {clb.from_user.last_name}", file=str(clb.from_user.id))
@ -618,6 +633,7 @@ async def callback_query_reapply_stop(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 due to typo in it")
await clb.message.edit(clb.message.text, reply_markup=None)
# ==============================================================================================================================