【问题标题】:Can't give quick reply options to twitter user using tweepy (Python)无法使用 tweepy (Python) 向 twitter 用户提供快速回复选项
【发布时间】:2021-01-17 20:28:53
【问题描述】:

我想使用 Tweepy 库和 Twitter 的 API 在 Python 中发送带有快速回复选项的直接消息。 Tweepy 文档说我可以使用以下代码发送带有快速回复选项的 DM:

API.send_direct_message(recipient_id, text[, quick_reply_type][, attachment_type][, attachment_media_id])

我尝试通过使用 Python 创建自己的选项来实现它,这就是我实现它的方式:

import tweepy
import time

#login credentials need to be filled here
auth = tweepy.OAuthHandler('','')
auth.set_access_token('', '')

api = tweepy.API(auth)


user = api.get_user("user's name")


options = [
            {
              "label": "I'm good",
              "description": "It means you're doing good",
              "metadata": "external_id_1"
            },
            {
              "label": "Not so good",
              "description": "It means you're not doing good",
              "metadata": "external_id_2"
            }
          ]
direct_message = api.send_direct_message(user.id, "Hey Man! How's it going?", quick_reply_type=options)

我最终得到了这个错误:

tweepy.error.TweepError: [{'code': 214, 'message': 'event.message_create.message_data.quick_reply: Unknown quick_reply type '}]

我什至尝试将这些选项放入 Python 对象中并使其可序列化为 JSON,但它最终仍然给出了相同的错误。我该怎么办?

【问题讨论】:

    标签: python twitter chatbot tweepy


    【解决方案1】:

    这是 Tweepy 中的一个已知错误,已确定并修复(请参阅 Github 上的拉取请求),但尚不可用。

    在合并之前,唯一的选择似乎是在本地修复 Tweepy 并使用自定义版本。

    【讨论】:

    • 啊不知道这是一个错误。我会尝试在本地修复它。谢谢。
    猜你喜欢
    • 2016-06-16
    • 2017-08-27
    • 2020-08-06
    • 2017-06-19
    • 2013-01-07
    • 1970-01-01
    • 2016-01-22
    • 2016-09-03
    • 2012-03-08
    相关资源
    最近更新 更多