wtelegramclient

Makeva reply like orginal message when copying with WTelegramClient


How does one get WtelegramClient to display replies(preview of the original message and reply message) when copying via listening for updates from one channel to another? I am handling the reply by having the original message and the reply under it but I would like to make it like the inbuilt reply display.

How I would like it to be as in default behaviour in the original channel

enter image description here

Current display in destination channel enter image description here

 private async Task<Task> DisplayMessage(MessageBase messageBase, 
 bool edit = false)
  {
    if (edit) Console.Write("(Edit): ");
    switch (messageBase)
  {
    case TL.Message m:
      if (m.Peer.ID == from.ID)
      {
        string message = $"{m.message}";
        Console.WriteLine(message);

        if (messageBase.ReplyTo != null)
        {
          var chats = await Client.Messages_GetAllChats();
          InputPeer peer = chats.chats[from.ID];
          Messages_MessagesBase repMessage = await Client.Messages_GetHistory(peer);

          TL.Message repliee = (TL.Message)repMessage.Messages[0];
          if (repMessage.Messages.Length > 0)
          {
            foreach (var msg in repMessage.Messages)
            {
              if (msg.ID == m.reply_to.reply_to_msg_id)
              {
                repliee = (TL.Message)msg;
              }
            }
          }

         
          TargetLog(repliee.message + Environment.NewLine + Environment.NewLine + 
          "UPDATE:" + Environment.NewLine + message);
         
        }
        else
        {
          await Client.Messages_ForwardMessages(from, new[] { messageBase.ID }, new[] { 
        WTelegram.Helpers.RandomLong() }, to, drop_author: true);
        }
      }
   private async Task TargetLog(string txt)
   {
      await Client.SendMessageAsync(to, txt);
    }

Solution

  • You can't make a reply with Messages_ForwardMessages.
    You will have to use SendMessageAsync to copy the message (see example) with parameter reply_to_msg_id being a msg ID in the target chat.

    Of course, that means you will have to remember in your program the mapping between the source msg IDs and the target replicated msg IDs to correctly map the msg ID it was replying to.

    Note that SendMessageAsync returns information about the sent message.