Делаю Telegram бот на python с помощью библиотеки pyTelegramBotApi. Суть в том, что у меня есть вот такой код
import telebot
from telebot import types
from clickupython import client
token = 'token' #здесь мой токен
bot = telebot.TeleBot(token)
c = client.ClickUpClient("token") #здесь мой токен
@bot.message_handler(commands=['start'])
def button_message(message):
markup=types.ReplyKeyboardMarkup(resize_keyboard=True)
item1=types.KeyboardButton("Просмотреть задачи")
item2=types.KeyboardButton("Создать задачу")
markup.add(item1, item2)
bot.send_message(message.chat.id,'Здравствуйте,{0.first_name} {0.last_name}, выберите действие:',reply_markup=markup)
@bot.message_handler(func=lambda call: True)
def message_reply(message):
if message.text=="Просмотреть задачи":
bot.send_message(message.chat.id, "ID | Имя | Описание | Создатель | Ссылка на задачу")
tasks = c.get_tasks("210333950")
for task in tasks:
bot.send_message(message.chat.id, task.id, " | ", task.name," | ", task.description, " | ", task.creator.username, " | ", task.url)
elif message.text=="Создать задачу":
bot.send_message(message.chat.id, "Я работаю над этим")
bot.infinity_polling()
А ошибка у меня вот такая
2022-09-06 17:51:57,345 (__init__.py:878 MainThread) ERROR - TeleBot: "Infinity polling exception: 'str' object has no attribute 'type'"
2022-09-06 17:51:57,346 (__init__.py:880 MainThread) ERROR - TeleBot: "Exception traceback:
Traceback (most recent call last):
File "C:\Users\Simon\PycharmProjects\pythonProject\venv\lib\site-packages\telebot\__init__.py", line 874, in infinity_polling
self.polling(non_stop=True, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "C:\Users\Simon\PycharmProjects\pythonProject\venv\lib\site-packages\telebot\__init__.py", line 946, in polling
self.__threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "C:\Users\Simon\PycharmProjects\pythonProject\venv\lib\site-packages\telebot\__init__.py", line 1021, in __threaded_polling
raise e
File "C:\Users\Simon\PycharmProjects\pythonProject\venv\lib\site-packages\telebot\__init__.py", line 977, in __threaded_polling
self.worker_pool.raise_exceptions()
File "C:\Users\Simon\PycharmProjects\pythonProject\venv\lib\site-packages\telebot\util.py", line 154, in raise_exceptions
raise self.exception_info
File "C:\Users\Simon\PycharmProjects\pythonProject\venv\lib\site-packages\telebot\util.py", line 98, in run
task(*args, **kwargs)
File "C:\Users\Simon\PycharmProjects\pythonProject2\main.py", line 25, in message_reply
bot.send_message(message.chat.id, task.id, " | ", task.name," | ", task.description, " | ", task.creator.username, " | ", task.url)
File "C:\Users\Simon\PycharmProjects\pythonProject\venv\lib\site-packages\telebot\__init__.py", line 1451, in send_message
apihelper.send_message(
File "C:\Users\Simon\PycharmProjects\pythonProject\venv\lib\site-packages\telebot\apihelper.py", line 271, in send_message
payload['entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(entities))
File "C:\Users\Simon\PycharmProjects\pythonProject\venv\lib\site-packages\telebot\types.py", line 1291, in to_list_of_dicts
res.append(MessageEntity.to_dict(e))
File "C:\Users\Simon\PycharmProjects\pythonProject\venv\lib\site-packages\telebot\types.py", line 1315, in to_dict
return {"type": self.type,
AttributeError: 'str' object has no attribute 'type'