anvarkhamidov

aasd

Oct 2nd, 2019
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.00 KB | None | 0 0
  1. @Poolitzer
  2.  
  3.  
  4. if data.data == "cancel_login":
  5.     welcome(update, context)
  6.     update.effective_message.delete()
  7.     del context.user_data['login']
  8.     del context.user_data['password']
  9.     return ConversationHandler.END
  10. this is in callback_handler
  11.  
  12.  
  13. @user_language
  14. def go_menu_timetable(update, context):
  15.     print(context.user_data)
  16.     update.effective_message.reply_markdown(_("msg_credentials_login"), reply_markup=inline_cancel_menu())
  17.     return TYPING_LOGIN
  18.  
  19. @user_language
  20. def get_auth_login(update, context):
  21.     message_id = update.effective_message.message_id-1
  22.     chat_id = update.effective_message.chat_id
  23.     login = update.effective_message.text
  24.     context.user_data['login'] = login
  25.     context.bot.delete_message(chat_id=chat_id, message_id=message_id)
  26.     update.effective_message.reply_markdown(text=_("msg_credentials_pass", params=[context.user_data['login']]), reply_markup=inline_cancel_menu())
  27.     return TYPING_PASS
  28.  
  29. @user_language
  30. def get_auth_pass(update, context):
  31.     message_id = update.effective_message.message_id - 1
  32.     chat_id = update.effective_message.chat_id
  33.     context.user_data['password'] = update.effective_message.text
  34.     context.bot.delete_message(chat_id=chat_id, message_id=message_id)
  35.     text = _("msg_credentials_is_correct", params=[context.user_data['login'], context.user_data['password']])
  36.     update.effective_message.reply_markdown(text, reply_markup=inline_cancel_menu())
  37.     return ConversationHandler.END
  38.  
  39. this is callbacks for conversationhandler
  40.  
  41.  
  42. auth_conv_handler = ConversationHandler(
  43.     entry_points=[MessageHandler(Filters.regex(_("cmd_timetable", locale="all")), go_menu_timetable, pass_user_data=True)],
  44.     states= {
  45.         TYPING_LOGIN:[MessageHandler(Filters.text, get_auth_login, pass_user_data=True)],
  46.         TYPING_PASS:[MessageHandler(Filters.text, get_auth_pass, pass_user_data=True)]
  47.     },
  48.     fallbacks=[CallbackQueryHandler(callback_handler)]
  49. )
  50. dp.add_handler(auth_conv_handler)
  51.  
  52. this is conversation handler
Add Comment
Please, Sign In to add comment