G
G
Goldd lol2021-08-30 00:20:14
Telegram
Goldd lol, 2021-08-30 00:20:14

A simple telegram bot with buttons does not work What should I do? worked with the same code?

The telegram bot doesn’t work, the window closes right away, even it doesn’t write anything to the console, it only closes in the python file and you can see the error text for 0.5 seconds here is the code

import telebot

bot = telebot.TeleBot('токен убрал')

keyboard1 = telebot.types.ReplyKeyboardMarkup()
keyboard1.row('Привет', 'Пока')

@bot.message_handler(commands=['start'])
def start_message(message):
    bot.send_message(message.chat.id, 'Привет, ты написал мне /start', reply_markup=keyboard1)

@bot.message_handler(content_types=['text'])
def send_text(message):
    if message.text.lower() == 'привет':
        bot.send_message(message.chat.id, 'Привет,морген ')
    elif message.text.lower() == 'пока':
        bot.send_message(message.chat.id, 'Прощай, создатель')
    elif message.text.lower() == 'я тебя люблю':
        bot.send_sticker(message.chat.id, '')

@bot.message_handler(content_types=['sticker'])
def sticker_id(message):
    print(message)

bot.polling()

the bot worked earlier with the same code now no I don’t know why on a laptop and PC it closes the python file

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question