K
K
kirzhq2021-07-22 14:52:09
Python
kirzhq, 2021-07-22 14:52:09

What is wrong with the Telegram bot code?

import telebot

TOKEN = 'token'
bot=telebot.Telebot = TOKEN

@bot.message_handler(commands=['start'])
def start(message):
    bot.send_sticker(message.chat.id, 'CAACAgIAAxkBAAECnZVg-UPv8J7kPhnbCpqULmLItyskwwACSAEAAntOKhBDvsTRe_qU_yAE')


terminal outputs:
[email protected] ~ % /usr/local/bin/python3 /Users/kirzhq/Documents/Progrm/bot.py
Traceback (most recent call last):
File "/Users/kirzhq/Documents/Progrm/bot. py", line 6, in
@bot.message_handler(commands=['start'])
AttributeError: 'str' object has no attribute 'message_handler'
?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stefan, 2021-07-22
@kir1g

bot=telebot.Telebot = TOKEN
Look at this line and think what's wrong

For lazy and beginners

bot = telebot.TeleBot("TOKEN")
Желательно в документацию заглядывать для начала, и только если там не понятно, то писать на форумы

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question