@Misha_dev

Почему виводит ошибку?

Почему виводит ошибку?
Вот код:
@bot.message_handler(commands=['start'])
def start(message):
    time.sleep(5)
    user_id = message.chat.id
    my_channel_id = -1001722012910
    statuss = ['creator', 'administrator', 'member']
    for i in statuss:
        if i == bot.get_chat_member(chat_id=my_channel_id, user_id=message.from_user.id).status:
            bot.send_message(message.chat.id, 'Привет')
            break
    else:
    markup = types.InlineKeyboardMarkup()
    button1 = types.InlineKeyboardButton("Подписаться", url='https://t.me/......')
    button2 = types.InlineKeyboardButton("Подписаться", url='https://t.me/.....')
    markup.add(button1, button2)
    bot.send_sticker(message.chat.id, "CAACAgIAAxkBAAIU7WPiUH_F3LRfcnuqPKG5x8VxqhItAAKNJgACWPrxShVcqS6dZHPYLgQ")
    bot.send_message(message.chat.id, "А подписочку?\nПосле того как подписался, напиши /start", reply_markup=markup)

Вот ошибка:
UnboundLocalError: cannot access local variable 'markup' where it is not associated with a value
  • Вопрос задан
  • 542 просмотра
Решения вопроса 1
@Wispik
bot.send_message(message.chat.id, 'Привет,)
После привет кавычка не закрыта.
Это даже подсветка тут на сайте показывает, я уже промолчу про IDE
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы