@B1ackCrow

Не отправляет сообщение в Notion So, как исправить?

Выдает ошибку когда отправляю сообщение в телеграмм, хотя должно передавать в Notion So

from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
from notion.client import NotionClient

# Telegram Bot API Token
telegram_token = '******'

# Notion API Token
notion_token = '*****'

# Notion Database URL
database_url = '*****'

# команда /start 
def start(update, context):
    context.bot.send_message(chat_id=update.effective_chat.id, text="Привет! Я готов принимать сообщения и отправлять их в Notion.")
# Отправка сообщение пользователя в NS
def handle_message(update, context):
    message = update.message.text

    # Создание клиента Notion
    client = NotionClient(token_v2=notion_token)
    # Получение базы данных по идентификатору
    database = client.get_collection_view(database_url)

    # Создание новой записи в базе данных Notion
    row = database.collection.add_row()
    row.title = message

    context.bot.send_message(chat_id=update.effective_chat.id, text="Сообщение успешно отправлено в Notion.")
# Основа которая направляет бота что делать
def main():
    updater = Updater(token=telegram_token, use_context=True)
    dispatcher = updater.dispatcher

    start_handler = CommandHandler('start', start)
    message_handler = MessageHandler(Filters.text & ~Filters.command, handle_message)

    dispatcher.add_handler(start_handler)
    dispatcher.add_handler(message_handler)

    updater.start_polling()

if __name__ == '__main__':
    main()


В консоли выдает ошибку

No error handlers are registered, logging exception.
Traceback (most recent call last):
File "C:\Users\kapla\AppData\Local\Programs\Python\Python39\lib\site-packages\telegram\ext\dispatcher.py", line 555, in process_update
handler.handle_update(update, self, check, context)
File "C:\Users\kapla\AppData\Local\Programs\Python\Python39\lib\site-packages\telegram\ext\handler.py", line 198, in handle_update
return self.callback(update, context)
File "C:\BowNotion\bot.py", line 23, in handle_message
database = client.get_collection_view(database_url)
File "C:\Users\kapla\AppData\Local\Programs\Python\Python39\lib\site-packages\notion\client.py", line 221, in get_collection_view
assert (
AssertionError: If 'url_or_id' is an ID (not a URL), you must also pass the 'collection'
  • Вопрос задан
  • 53 просмотра
Пригласить эксперта
Ответы на вопрос 1
@benzcrew
если «url_or_id» является идентификатором (а не URL-адресом), вы также должны передать 'collection'
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы