K
K
kirzhq2021-06-14 22:12:29
Python
kirzhq, 2021-06-14 22:12:29

Gives a bunch of errors when writing a bot in Python. What to do?

I'm new in this business, please don't swear too much)))

Code:


import telebot

API_TOKEN = 'my token (it's here in the code)'
bot = telebot.TeleBot(API_TOKEN)

@bot.message_handler(commands='start')
def send_welcome(message):
bot.reply_to(message.chat.id, "Hi, I'm a feature test bot")

@bot.message_handler(commands='help')
def send_help(message):
bot.send_message(message.chat.id, "What can I do for you?")

@bot.message_handler( func=lambda m: True)
def echo_all(message):
if message.text == 'Hi':
bot.send_message(message.chat.id, 'Hi man!')
elif message.text == 'hi':
bot.send_message(message.chat.id, 'Hello, man!'
bot.polling()


In the code, there are not even lines that are indicated in the error
Crashing errors:

60c7a9e74b652406657387.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
o5a, 2021-06-14
@kirzhq

Parameters (commands, types) in the handler must be specified as a list:
@bot.message_handler(commands=['start'])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question