Advertisement
Iammrjude

Untitled

Apr 27th, 2020
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.37 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. import telebot
  4. from telebot import types
  5.  
  6.  
  7. API_TOKEN=<'api token'>
  8.  
  9. bot = telebot.TeleBot(API_TOKEN)
  10.  
  11. user_dict = {}
  12.  
  13.  
  14. class User:
  15.     def __init__(self, email):
  16.         self.email = email
  17.  
  18.        
  19. # Handle '/start' and '/help'
  20. @bot.message_handler(commands=['help', 'start'])
  21. def send_welcome(message):
  22.     e_mail=''
  23.     msg = bot.reply_to(message,'๐Ÿ“ง UPDATE EMAIL\n\nCurrent email: '+e_mail+'\n\n๐Ÿ”ป Please send me the new email address for your account.\n')
  24.     bot.register_next_step_handler(msg, process_email_step)
  25.  
  26.  
  27. def process_email_step(message):
  28.     try:
  29.         #global user
  30.         chat_id = message.chat.id
  31.         email = message.text
  32.         user = User(email)
  33.         user_dict[chat_id] = user
  34.         e_mail=user.email
  35.         msg = bot.reply_to(message,'๐Ÿ“ง UPDATE EMAIL\n\nโœ… Your email address updated!\n\nCurrent email: '+user.email)
  36.     except Exception as e:
  37.         bot.reply_to(message, 'oooops')
  38.  
  39.        
  40. # Enable saving next step handlers to file "./.handlers-saves/step.save".
  41. # Delay=2 means that after any change in next step handlers (e.g. calling register_next_step_handler())
  42. # saving will hapen after delay 2 seconds.
  43. bot.enable_save_next_step_handlers(delay=2)
  44.  
  45. # Load next_step_handlers from save file (default "./.handlers-saves/step.save")
  46. # WARNING It will work only if enable_save_next_step_handlers was called!
  47. bot.load_next_step_handlers()
  48.  
  49. bot.polling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement