import telebot
import config
from telebot import types
bot = telebot.TeleBot(config.TOKEN)
@bot.message_handler(commands=['start'])
def lalala(message):
bot.send_message(message.chat.id, "привет".format(message.from_user, bot.get_me()),
parse_mode='html', reply_markup=markup)
# keyboard
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton("от ppp")
item2 = types.KeyboardButton("от ooo")
markup.add(item1, item2)
@bot.message_handler(content_types=['text'])
def lalala(message):
if message.chat.type == 'private':
if message.text == 'от ppp':
bot.send_message(message.chat.id, 'Отлично! Ты подписан на уведомления от ppp')
elif message.text == 'от ooo':
bot.send_message(message.chat.id, 'Отлично! Ты подписан на уведомления от ooo')
else:
bot.send_message(message.chat.id, 'Я не знаю что ответить ')
# RUN
bot.polling(none_stop=True)
ВЫДАЕТ ОШИБКУ
Traceback (most recent call last):
File "E:\New folder\bot.py", line 35, in
bot.polling(none_stop=True)
File "C:\Users\vadim\AppData\Roaming\Python\Python38\site-packages\telebot\__init__.py", line 496, in polling
self.__threaded_polling(none_stop, interval, timeout, long_polling_timeout)
File "C:\Users\vadim\AppData\Roaming\Python\Python38\site-packages\telebot\__init__.py", line 555, in __threaded_polling
raise e
File "C:\Users\vadim\AppData\Roaming\Python\Python38\site-packages\telebot\__init__.py", line 518, in __threaded_polling
self.worker_pool.raise_exceptions()
File "C:\Users\vadim\AppData\Roaming\Python\Python38\site-packages\telebot\util.py", line 117, in raise_exceptions
raise self.exception_info
File "C:\Users\vadim\AppData\Roaming\Python\Python38\site-packages\telebot\util.py", line 69, in run
task(*args, **kwargs)
File "E:\New folder\bot.py", line 11, in lalala
parse_mode='html', reply_markup=markup)
UnboundLocalError: local variable 'markup' referenced before assignment