Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import telebot
- from telebot import types
- API_TOKEN=<'api token'>
- bot = telebot.TeleBot(API_TOKEN)
- user_dict = {}
- class User:
- def __init__(self, email):
- self.email = email
- # Handle '/start' and '/help'
- @bot.message_handler(commands=['help', 'start'])
- def send_welcome(message):
- e_mail=''
- 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')
- bot.register_next_step_handler(msg, process_email_step)
- def process_email_step(message):
- try:
- #global user
- chat_id = message.chat.id
- email = message.text
- user = User(email)
- user_dict[chat_id] = user
- e_mail=user.email
- msg = bot.reply_to(message,'๐ง UPDATE EMAIL\n\nโ Your email address updated!\n\nCurrent email: '+user.email)
- except Exception as e:
- bot.reply_to(message, 'oooops')
- # Enable saving next step handlers to file "./.handlers-saves/step.save".
- # Delay=2 means that after any change in next step handlers (e.g. calling register_next_step_handler())
- # saving will hapen after delay 2 seconds.
- bot.enable_save_next_step_handlers(delay=2)
- # Load next_step_handlers from save file (default "./.handlers-saves/step.save")
- # WARNING It will work only if enable_save_next_step_handlers was called!
- bot.load_next_step_handlers()
- bot.polling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement