AttributeError:“ LabeledPrice”对象没有属性“ to_dict”

时间:2020-09-12 08:14:33

标签: telegram telegram-bot python-telegram-bot

我想为电报机器人(pyTelegramBotAPI)添加付款。 但是当我使用payments_example.py from GitHub时-它会给出异常:
AttributeError: 'LabeledPrice' object has no attribute 'to_dict'

有人可以帮我吗?

shipping_options = [
    ShippingOption(id='instant', title='WorldWide Teleporter').add_price(LabeledPrice('Teleporter', 1000))
]


@bot.shipping_query_handler(func=lambda query: True)
def shipping(shipping_query):
    print(shipping_query)
    bot.answer_shipping_query(
        shipping_query.id,
        ok=True,
        shipping_options=shipping_options,
        error_message='Oh, seems like our Dog couriers are having a lunch right now. Try again later!'
    )

1 个答案:

答案 0 :(得分:0)

我刚刚在使用 python-telegram-bot 版本 13.5 时遇到了这个问题,而降级到 13.4.1 暂时修复了该问题(通过 pip3 install 'python-telegram-bot==13.4.1')。

发生在 Ubuntu 20.04 和 Python 3.8.5 上。