@DinkaSugoia

Почему не запускается телеграм бот?

import telebot
from telebot import types
import random
token = '**'


bot = telebot.TeleBot(token)

@bot.message_handler(commands = ['start'])
def start(message):
	markup = types.ReplyKeyboardMarkup(resize_keyboard = True)
	item1 = types.KeyboardButton('Рандомное число')
	item2 = types.KeyboardButton('Офисный пк')
	item3 = types.KeyboardButton('Игровой пк')

	markup.add(item1, item2, item3)

	bot.send_message(message.chat.id, 'Привет', reply_markup = markup)

	@bot.message_handler(content_types = ['text'])
	def bot_message(message):
		if message.text == 'Рандомное число':
			bot.send_message(message.chat.id, 'ваше число: ' +str(random.randint(0, 1000)))

		elif message.text == 'Офисный пк':
			markup = types.ReplyKeyboardMarkup(resize_keyboard = True)
			item1 = types.KeyboardButton('сборка')
			item2 = types.KeyboardButton('сборка такая то')
			back = types.KeyboardButton('назад')
			markup.add(item1, item2, back)
			bot.send_message(message.chat.id, 'Офисный пк', reply_markup = markup)

		elif message.text == 'Игровой пк':
			markup = types.ReplyKeyboardMarkup(resize_keyboard = True)
			item1 = types.KeyboardButton('Комлектующие')
			item2 = types.KeyboardButton('Комлектующие такие то')
			back = types.KeyboardButton('назад')
			markup.add(item1, item2, back)
			bot.send_message(message.chat.id, 'Игровой пк', reply_markup = markup)

		elif message.text == 'Назад':
			markup = types.ReplyKeyboardMarkup(resize_keyboard = True)
			item1 = types.KeyboardButton('Рандомное число')
			item2 = types.KeyboardButton('Офисный пк')
			item3 = types.KeyboardButton('Игровой пк')
			markup.add(item1, item2, item3)
			bot.send_message(message.chat.id, 'Назад', reply_markup = markup)



			bot.polling(none_stop = True)
  • Вопрос задан
  • 54 просмотра
Пригласить эксперта
Ответы на вопрос 1
@Filipp_SC
PYTHON♥️
Попробуйте такую конструкцию
if __name__ == '__main__':
  bot.polling(none_stop=True)

таб делать не надо.
Ответ написан
Комментировать
Ваш ответ на вопрос

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

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