0

exactly 'str' object.

import telebot  
bot = telebot.TeleBot = ('api') 
@bot.message_handler(content_types=['text'])
def get_text_messages(message):     
if message.text == "hello":   
    bot.send_message(message.from_user.id, "hello")
bot.polling(none_stop=True, interval=0)

what`s wrong?

I'm trying to create a telegram bot for the first time

1 Answer 1

1
bot = telebot.TeleBot = ('api')

should be

bot = telebot.TeleBot('api')

The current version just makes telebot.Telebot to be equal to 'api', then bot to be equal to telebot.Telebot

As a result, bot equals 'api' which is a str, hence the error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.