属性错误:“NoneType”对象没有属性“message_id”

发布于 2025-01-20 15:47:07 字数 1506 浏览 0 评论 0 原文

我已经在Python-Telegram-bot包装器中创建了回调函数。

def add2(update: Updater, context: CallbackContext):
    query = update.callback_query  
    # add()
    query2 = link1
    _mirror(bot, update, query2)
    query.answer()

但是我会得到属性:'nontype'objcet没有属性'message_id'

2022-04-12 06:37:46,195 - telegram.ext.dispatcher - ERROR - No error handlers are registered, logging exception.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/telegram/ext/dispatcher.py", line 343, in process_update
    handler.handle_update(update, self, check, context)
  File "/usr/local/lib/python3.8/dist-packages/telegram/ext/handler.py", line 117, in handle_update
    return self.callback(update, context)
  File "/usr/src/app/bot/modules/mirror.py", line 266, in add2
    _mirror(bot, update, query2)
  File "/usr/src/app/bot/modules/mirror.py", line 228, in _mirror
    listener = MirrorListener(bot, update,isTar, tag, extract)
  File "/usr/src/app/bot/modules/mirror.py", line 39, in __init__
    super().__init__(bot, update)
  File "/usr/src/app/bot/helper/mirror_utils/status_utils/listeners.py", line 6, in __init__
    self.uid = self.message.message_id
AttributeError: 'NoneType' object has no attribute 'message_id'

是_mirror函数的链接:

I Have Created A CallBack Function In Python-Telegram-Bot Wrapper.

def add2(update: Updater, context: CallbackContext):
    query = update.callback_query  
    # add()
    query2 = link1
    _mirror(bot, update, query2)
    query.answer()

But I Am Getting AttributeError: 'NoneType' objcet Has No Attribute 'Message_id'

2022-04-12 06:37:46,195 - telegram.ext.dispatcher - ERROR - No error handlers are registered, logging exception.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/telegram/ext/dispatcher.py", line 343, in process_update
    handler.handle_update(update, self, check, context)
  File "/usr/local/lib/python3.8/dist-packages/telegram/ext/handler.py", line 117, in handle_update
    return self.callback(update, context)
  File "/usr/src/app/bot/modules/mirror.py", line 266, in add2
    _mirror(bot, update, query2)
  File "/usr/src/app/bot/modules/mirror.py", line 228, in _mirror
    listener = MirrorListener(bot, update,isTar, tag, extract)
  File "/usr/src/app/bot/modules/mirror.py", line 39, in __init__
    super().__init__(bot, update)
  File "/usr/src/app/bot/helper/mirror_utils/status_utils/listeners.py", line 6, in __init__
    self.uid = self.message.message_id
AttributeError: 'NoneType' object has no attribute 'message_id'

Below Is The Link Of _mirror function:
https://github.com/lzzy12/python-aria-mirror-bot/blob/master/bot/modules/mirror.py

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽清梦 2025-01-27 15:47:07

_mirror 函数将 update 传递给 MirrorListener,它显然假设 update.message 不是 None< /代码>。但 add2 回调显然用作 CallbackQueryHandler 的回调,因为您访问 update.callback_query

the _mirror function passes the update to MirrorListener which apparently assumes that update.message is not None. but the add2 callback is apparently used as callback for a CallbackQueryHandler, since you access update.callback_query.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文