S
S
svntxxnx2021-01-04 08:15:39
Python
svntxxnx, 2021-01-04 08:15:39

Pytelegrambotapi Why is there an error ('list' object is not callable)?

My code

animals = []
bot = telebot.TeleBot(TOKEN)

@bot.message_handler(commands=['start'])
def start(message):
markup = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)
btn1 = types .InlineKeyboardButton("Buy Seeds")
btn3 = types.InlineKeyboardButton("Sell Harvest")
btn4 = types.InlineKeyboardButton("Buy Pet")
btn5 = types.InlineKeyboardButton("My Farm")
markup.add(btn1, btn3, btn4 , btn5)

send = f"Hi {message.from_user.first_name} {message.from_user.last_name}\nYou can harvest and earn on this bot"
bot.send_message(message.chat.id, send, parse_mode='html', reply_markup=markup)

@bot.message_handlers(content_types=['text'])
def txt(message):
msg = message.text

if msg == "Buy Pet":
ma = types.ReplyKeyboardMarkup()
b1 = types.InlineKeyboardButton("Buy")
b2 = types.InlineKeyboardButton("Sell")
bot.send_message(message.chat.id, "You have" + [animals] + "pets")


bot.polling(none_stop=True)

When I run it, it gives an error ('list' object is not callable)

How to solve this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ant1panov, 2021-09-28
@Ant1panov

I have a problem with the line @bot.message_handlers(commands=["start"]) in the function:
@bot.message_handlers(commands=["start"])
def send_welcome(message):
bot.reply_to(message.chat.id, "Hi, the bot is working")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question