AttributeError: 'Message' object has no attribute 'message_id' (Pyrogram)
AttributeError: 'Message' object has no attribute 'message_id' (Pyrogram)
创建了一个名为 redeemcode 的命令,要求用户输入兑换代码并将其存储为变量 '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)
我收到了这个错误
(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,谁能帮我解决这个问题?
除了您无法从机器人发送的消息中得到回复之外,message.message_id
已被弃用,取而代之的是 message.id
,以便与其他类型更加一致,像 chat.id
、photo.id
或 video.id
.
请参阅 Pyrogram's v2 Release Notes:
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.
创建了一个名为 redeemcode 的命令,要求用户输入兑换代码并将其存储为变量 '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)
我收到了这个错误
(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,谁能帮我解决这个问题?
除了您无法从机器人发送的消息中得到回复之外,message.message_id
已被弃用,取而代之的是 message.id
,以便与其他类型更加一致,像 chat.id
、photo.id
或 video.id
.
请参阅 Pyrogram's v2 Release Notes:
Message.message_id becomes Message.id: For consistency reasons,
Message.message_id
has been renamed toMessage.id
. This makes it a less redundant name and will reflect with all other types that have the.id
attribute.