How can I comment on a post in a telegram channel (WTelegramClient)?

1k Views Asked by At

How can I comment on a post in a channel using WTelegramClient? I didn't find anything similar in the examples. If possible, could you provide an example of sending a comment to a specific post in a channel. https://github.com/wiz0u/WTelegramClient

1

There are 1 best solutions below

0
On

Searching for "comment" in the full API Methods list, you would quickly find 4 methods dealing with message threads.
And in particular messages.getDiscussionMessage seems interesting as it matches a channel message with the corresponding message within the discussion/comment group associated with the channel.

Once you have that group message, you simply have to reply to it in that group.

    // This part is just to target the last message of a channel
    InputPeer channel = await client.Contacts_ResolveUsername("channelName");
    var peerDialogs = await client.Messages_GetPeerDialogs(channel);
    int msg_id = peerDialogs.dialogs[0].TopMessage;

    // Find the matching discussion group message and reply to it:
    var discussion = await client.Messages_GetDiscussionMessage(channel, msg_id);
    var groupMsg = discussion.messages[0];
    await client.SendMessageAsync(discussion.chats[groupMsg.Peer.ID], "test", reply_to_msg_id: groupMsg.ID);