Не получаеться запустить бота Телеграм
import telebot
import config
from telebot import types
import random
from telebot import types
bot = telebot.TeleBot(config.TOKEN, threaded=False)
@bot.message_handler(commands=['start'])
def welcome(message):
sti = open('static/welcome.webp' , 'rb')
bot.send_sticker(message.chat.id, sti)
# keyboard
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton("Рандомное число")
item2 = types.KeyboardButton("? Как дела?")
markup.add(item1, item1)
bot.send_message(message.chat.id, "Добро пожаловать, {0.first_name}! \nЯ - <b>{1.first_name}</b>, бот созданный чтобы быть подопытным кроликом.".format(message.from_user, bot.get_me()),)
parse_mode='html', reply_markup=markup
@bot.message_handler(content_types=['text'])
def send_echo(message):
bot.send_message(message.chat.id, message.text)
if message.chat.type == 'private':
if message.text == 'Рандомное число':
bot.send_message(message.chat.id, str(random.randint(0,100)))
elif message.text == '? Как дела?':
bot.send_message(message.chat.id, 'Отлично, сам как?')
else:
bot.send_message(message.chat.id, 'Я не знаю что ответить ?')
# RUN
bot.polling( none_stop = True )
После в консоли как пишу python bot.py вылазит данная ошибка:
File "C:\Python\bot.py", line 23
parse_mode='html', reply_markup=markup
IndentationError: unexpected indent
Ответы (1 шт):
Автор решения: осел
→ Ссылка
Поместите parse_mode='html', reply_markup=markup в параметры вызываемой функции bot.send_message.
@bot.message_handler(commands=['start'])
def welcome(message):
sti = open('static/welcome.webp' , 'rb')
bot.send_sticker(message.chat.id, sti)
# keyboard
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton("Рандомное число")
item2 = types.KeyboardButton("? Как дела?")
markup.add(item1, item1)
bot.send_message(message.chat.id, "Добро пожаловать, {0.first_name}! \nЯ - <b>{1.first_name}</b>, бот созданный чтобы быть подопытным кроликом.".format(message.from_user, bot.get_me()), parse_mode='html', reply_markup=markup)