attributeError:'消息'对象没有属性' message_id' (Proragram)

发布于 2025-02-02 23:29:10 字数 1015 浏览 3 评论 0原文

创建了一个名为edeemcode的命令,要求用户提供兑换代码作为输入,并将其存储为变量“代码”

@bot.on_message(filters.command('redeemcode'))
def redeemcode(bot, message):
    message.reply_text("Send the code to redeem")
    code = bot.get_messages(chatid, message_ids=message.message_id)

而我遇到了此错误

(c) Microsoft Corporation. All rights reserved.

D:\Genshin Bot>C:/Python310/python.exe "d:/Genshin Bot/bot.py"
ERROR:pyrogram.dispatcher:'Message' object has no attribute 'message_id'
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\pyrogram\dispatcher.py", line 242, in handler_worker
    await self.loop.run_in_executor(
  File "C:\Python310\lib\concurrent\futures\thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "d:\Genshin Bot\bot.py", line 67, in redeemcode
    code = bot.get_messages(chatid, message_ids=message.message_id)
AttributeError: 'Message' object has no attribute 'message_id'

,问题是获得消息ID的问题,有人可以帮助我吗?

Created a command named redeemcode, to ask the user for redeem code as input and storing it as a variable 'code'

heres the code:

@bot.on_message(filters.command('redeemcode'))
def redeemcode(bot, message):
    message.reply_text("Send the code to redeem")
    code = bot.get_messages(chatid, message_ids=message.message_id)

and I am getting this error

(c) Microsoft Corporation. All rights reserved.

D:\Genshin Bot>C:/Python310/python.exe "d:/Genshin Bot/bot.py"
ERROR:pyrogram.dispatcher:'Message' object has no attribute 'message_id'
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\pyrogram\dispatcher.py", line 242, in handler_worker
    await self.loop.run_in_executor(
  File "C:\Python310\lib\concurrent\futures\thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "d:\Genshin Bot\bot.py", line 67, in redeemcode
    code = bot.get_messages(chatid, message_ids=message.message_id)
AttributeError: 'Message' object has no attribute 'message_id'

The problem is with getting the message id , can anyone help me with this?

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

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

发布评论

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

评论(1

残月升风 2025-02-09 23:29:10

除了您无法在发送的消息中从消息中回复消息的事实,message.message_id已对message.id demecement overeme 与其他类型一致,例如chat.idphoto.id,或video.id.id

参见 pyrogram的v2发行笔记为此:

message.message_id stemess.id :出于一致原因,message.message_id已重命名为message.id。这使其成为一个冗余名称,并将用具有.id属性的所有其他类型进行反映。

Besides the fact that you cannot get replies to a message from the message you as the bot sent, message.message_id has been deprecated in favor of message.id, to be more consistent with other types, like chat.id, photo.id, or video.id.

See Pyrogram's v2 Release Notes for this:

Message.message_id becomes Message.id: For consistency reasons, Message.message_id has been renamed to Message.id. This makes it a less redundant name and will reflect with all other types that have the .id attribute.

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