added deleting the captcha if user leaves
This commit is contained in:
parent
f9674a100b
commit
b933487c47
2 changed files with 8 additions and 0 deletions
|
|
@ -52,6 +52,8 @@ async def solve_captcha(update, context, user_data):
|
||||||
msg = await update.callback_query.edit_message_text(text=text, reply_markup=reply_markup)
|
msg = await update.callback_query.edit_message_text(text=text, reply_markup=reply_markup)
|
||||||
else:
|
else:
|
||||||
msg = await update.message.reply_photo("{}/{}".format(os.getenv('DATA_FOLDER'), user_data["captcha_file"]), caption=text, reply_markup=reply_markup)
|
msg = await update.message.reply_photo("{}/{}".format(os.getenv('DATA_FOLDER'), user_data["captcha_file"]), caption=text, reply_markup=reply_markup)
|
||||||
|
user_data['captcha_message_id'] = msg.message_id
|
||||||
|
save_case_file(update.message.chat.id, user_data)
|
||||||
context.job_queue.run_once(delete_message, int(os.getenv('CAPTCHA_EXPIRES')), data={'chat_id': msg.chat_id, 'message_id': msg.message_id})
|
context.job_queue.run_once(delete_message, int(os.getenv('CAPTCHA_EXPIRES')), data={'chat_id': msg.chat_id, 'message_id': msg.message_id})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,12 @@ async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE) ->
|
||||||
await solve_captcha(update, context, user_data)
|
await solve_captcha(update, context, user_data)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# new user leaves the chat before completing the captcha
|
||||||
|
elif 'left_chat_participant' in update.message.api_kwargs:
|
||||||
|
user_data = load_case_file(update.message.chat_id, update.message.api_kwargs['left_chat_participant']['id'])
|
||||||
|
if not user_data['captcha_solved']:
|
||||||
|
await context.bot.delete_message(chat_id=update.message.chat_id, message_id=user_data['captcha_message_id'])
|
||||||
|
|
||||||
|
|
||||||
async def menu_button(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
async def menu_button(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||||
query = update.callback_query
|
query = update.callback_query
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue