Answer the question
In order to leave comments, you need to log in
Task(*args, **kwargs) error in python telegram bot code, how to fix?
According to my idea, the bot had to respond to certain messages with an image.
When I sent a certain message 1 time, everything was fine, but when I sent a message 2 times, the following error appeared:
File "C:\Users\Zlaya_Belka\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\util.py", line 59, in run
task(*args, **kwargs)
File "E:\1\bot1.py", line 10, in get_text_messages
bot.send_photo(message.chat.id,serdechko1)
File "C:\Users\Zlaya_Belka\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\__init__.py", line 635, in send_photo
apihelper.send_photo(self.token, chat_id, photo, caption, reply_to_message_id, reply_markup,
File "C:\Users\Zlaya_Belka\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\apihelper.py", line 262, in send_photo
return _make_request(token, method_url, params=payload, files=files, method='post')
File "C:\Users\Zlaya_Belka\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\apihelper.py", line 56, in _make_request
return _check_result(method_name, result)['result']
File "C:\Users\Zlaya_Belka\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\apihelper.py", line 75, in _check_result
raise ApiException(msg, method_name, result)
import telebot
bot = telebot.TeleBot('ТОКЕН')
serdechko1 = open('1/photo/serdechki1.jpg', 'rb')
@bot.message_handler(content_types=['text'])
def get_text_messages(message):
if message.text == "❤️":
bot.send_photo(message.chat.id,serdechko1)
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "❣️":
bot.send_message(message.chat.id, "❣️")
elif message.text == "":
bot.send_message(message.chat.id, "")
elif message.text == "":
bot.send_message(message.chat.id, "")
bot.polling(none_stop=True, interval=0)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question