Telegram allows commenting on a channel post or on a generic supergroup message, thanks to message threads.
https://core.tlgr.org/api/threads
我收到频道中的最后一条消息
private async Task<TLMessage> GetLastMessage(TLChannel channelFrom)
{
TLChannelMessages resp = (TLChannelMessages)await _client.GetHistoryAsync(new TLInputPeerChannel()
{
ChannelId = channelFrom.Id,
AccessHash = channelFrom.AccessHash ?? 0,
}, limit: 1000);
TLMessage lastMessage = (TLMessage)resp.Messages?.Where(x => x is TLMessage).First();
return lastMessage;
}
我可以将其转发到另一个频道/聊天:
public async Task ReplyInDiscussion(TLChannel channelFrom, TLChannel chatTo)
{
TLMessage lastMessage = await GetLastMessage(channelFrom);
TLMessage lastChatMessage = await GetLastForwardMessage(chatTo, channelFrom.Id, lastMessage.Id);
await ReplyTo(chatTo, "Text", lastChatMessage.Id);
}
public Task ReplyTo(TLChannel channelTo, string message, int? replyMsgId = null)
{
TLAbsInputPeer to = new TLInputPeerChannel()
{
ChannelId = channelTo.Id,
AccessHash = channelTo.AccessHash ?? 0,
};
return ReplyTo(to, message, replyMsgId);
}
private async Task ReplyTo(TLAbsInputPeer to, string message, int? replyMsgId = null)
{
var req = new TLRequestSendMessage()
{
Peer = to,
Message = message,
RandomId = Helpers.GenerateRandomLong(),
ReplyToMsgId = replyMsgId,
};
await _client.SendRequestAsync<TLUpdates>(req);
}
我需要专门针对收到的消息发表评论
我不明白如何做到这一点,这对我来说很难