S
S
Shapito2292021-09-16 15:49:58
Python
Shapito229, 2021-09-16 15:49:58

How to fix TypeError: message_handler() got an unexpected keyword argument 'commands' error?

import telebot

bot = telebot.TeleBot('token')

@bot.message_handler(commands=['start'])
def start_message(message):
    bot.send_message(message.chat.id, "Привет")

@bot.message_handler(content_types=['text'])
def get_text_messages(message):
    if message.text == "Привет":
        bot.send_message(message.chat.id, "Привет, чем я могу тебе помочь?")
    elif message.text == "/help":
        bot.send_message(message.chat.id, "Напиши привет")
    else:
        bot.send_message(message.chat.id, "Я тебя не понимаю. Напиши /help.")


if __name__ == "name":
bot.infinity_polling()

Traceback (most recent call last):
  File "C:\Users\Пользователь\PycharmProjects\pythonProject2\telebot1.py", line 6, in <module>
    @bot.message_handler(commands=['start'])
TypeError: message_handler() got an unexpected keyword argument 'commands'

Process finished with exit code 1

61433d7401800907345305.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mashincode, 2021-09-17
@mashincode

Try to rewrite commands, maybe you wrote in Cyrillic

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question