TLSharp Telegram Submit Comment

155 views Asked by At
Telegram allows commenting on a channel post or on a generic supergroup message, thanks to message threads.

https://core.tlgr.org/api/threads

I get the last messages in the channel

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;
        }

I can forward it to another channel / chat:

 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);
        }

I need to leave a comment specifically for the received message

example

I do not understand how to do this, it is very difficult for me

0

There are 0 answers