如何使用telethon中的getReplipeRequest呼叫
有API方法 message.getReplies 在telegram api中,同等的是 functions.messages.messages.getRepliesRepliesRequest TELETHON中。 但是,此方法没有将预期的答复/评论返回到帖子中。取而代之的是,它返回多个消息,包括对所请求的Message_ID和其他消息的答复,甚至还不是对所请求的Message_ID的答复。
for conv in client.iter_messages(channel.id):
if conv.reply_to:
# get parent message this message reply to
original_message = conv.get_reply_message()
try:
#iterate all the replies for the parent message
for reply in client.iter_messages(channel.id,
reply_to=original_message.id):
print('\tReply message -> ', reply.to_dict())
except telethon.errors.rpcerrorlist.MsgIdInvalidError:
print('exception ***************')
在这里,它将答复返回到参数revery_to
中的输入消息。
(我检查了方法调用的响应(内部循环)及其revery_to_to_msg_id
与我要求获得结果的响应不同)。
我无法理解这些答复的行为。
另外,Telegram API文档在示例和外观上的形状不好。
- 什么消息被视为
回复
对电报中的消息? - 电报如何决定消息是回复还是普通消息?
- 如果消息是答复,那么这是一个答复?
There is api method messages.getReplies in Telegram API and the equivalent of the same is
functions.messages.GetRepliesRequest in the Telethon.
But this method is not returning the expected replies/comments to the post. Instead, it returns multiple messages including the replies to the requested message_id and other messages also which are not even the replies to the requested message_id.
for conv in client.iter_messages(channel.id):
if conv.reply_to:
# get parent message this message reply to
original_message = conv.get_reply_message()
try:
#iterate all the replies for the parent message
for reply in client.iter_messages(channel.id,
reply_to=original_message.id):
print('\tReply message -> ', reply.to_dict())
except telethon.errors.rpcerrorlist.MsgIdInvalidError:
print('exception ***************')
Here it returns the replies to the input message.id in the argument reply_to
including the messages which are not the replies to the input message.id.
(I checked the response from of the method call(inner for loop) and their reply_to_msg_id
differs from what i requested to get the result).
I could not understand the behaviour of these replies getting in the result.
Also Telegram API docs are not good in shape with example and explantion.
- What and how messages are considered as
reply
to the message in the telegram? - How telegram decides upon the messages whether it is a reply or a normal message?
- if a message is reply, then to which message this is a reply?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
给定一个启用注释的广播频道(例如,频道的用户名是
用户名
),以及带有消息ID 1001的频道帖子开始(注释)的帖子,以下代码将打印所有注释对于Channel用户名
中的1001张,这等同于单击Telegram桌面中的“#comment(s)”按钮。不幸的是,我无法在这里复制您提到的内容:
现在,对于其他问题:
让我们从不同角度看一下问题:
send_message
comment_to
。首先,
message.getDiscussionMessage
必须在源广播频道上使用源消息ID使用。这将返回链接的“讨论Megagroup频道”中的相应“讨论消息”。现在,
Message.SendMessage
可以使用链接的讨论中的消息将消息发送到回复对相应的讨论消息。如您所见,“注释”只是“回复”讨论组的相应消息。因此,名称,
回复>
,iter_messages
。在给定的聊天中,消息可以在同一聊天中回复其他以前的消息(在Telethon,
Message.reply_to
)中。但是,对于频道评论,它们也以某种方式回答(只是在不同的聊天中),因此参数名称。我试图坚持电报的命名惯例,并通过记录参数来解决混乱,但这可能是错误的选择。这可以通过
message.reply_to
找到。Given a broadcast channel with comments enabled (let's say the channel's username is
username
), and a post with a discussion started (comments) for the channel post with message ID 1001, the following code will print all comments for post 1001 in channelusername
:This is equivalent to clicking on the "# comment(s)" button in Telegram Desktop. Unfortunately I was not able to reproduce what you mention here:
Now, for the other questions:
Let's look at the problem from a different angle:
send_message
withcomment_to
.First,
messages.getDiscussionMessage
must be used on the source broadcast channel with the source message ID. This will return the corresponding "discussion message" in the linked "discussion megagroup channel".Now,
messages.sendMessage
can be used to send a message in the linked discussion megagroup channel to reply to the corresponding discussion message.As you can see, "comments" are simply "replies to" the corresponding message of the discussion group. Hence the name,
reply_to
, duringiter_messages
.In a given chat, messages can reply to other previous messages in the same chat (in Telethon,
message.reply_to
). However, for channel comments, they're also replies in a way (just in a different chat), hence the parameter name. I tried to stick with Telegram's naming convention and solve the confusion by documenting the parameter but that might've been the wrong choice.This can be found through
message.reply_to
.