Forwarding a message using the TLSharp library (C #)

I am connecting to the Telegram API with this C # library: TLSharp

There are not enough resources for this library, I'm trying to forward a message to a channel.

I'm not sure how to get the channel peer id message (for input function parameters ahead)

 var store = new FileSessionStore(); var client = new TelegramClient(Properties.Settings.Default.apiID, Properties.Settings.Default.apiHash, store, "session"); await client.ConnectAsync(); var dialogs = (TLDialogs)await client.GetUserDialogsAsync(); var chat = dialogs.chats.lists .OfType<TLChannel>() .SingleOrDefault(a=>a.title=="test"); await client.SendRequestAsync<TLAbsUpdates>( new TLRequestForwardMessage() { id = 2, peer = new TLInputPeerChannel() { channel_id = chat.id, access_hash = chat.access_hash.Value }, random_id = Helpers.GenerateRandomLong() }); 

I get this error message:

{"PEER_ID_INVALID"}

Please help me what peer identifier is and how can I get it and use it to forward a message using TLSharp. Thanks.

+5
source share
2 answers

This code can be used for forwarding.

**

 await client.SendRequestAsync<TLAbsUpdates>( new TLRequestForwardMessage() { id = item2.Id, peer = new TLInputPeerChat() { chat_id = item.id }, random_id = Helpers.GenerateRandomLong(), }); --------------------------------------- 

** ---------------------------------

+2
source

You can do this with this nice trick, which is fun: this code is below:

 new TLInputPeerChannel { channel_id = chat.id, access_hash = cha.access_hash.Value }, offset, maxId, limit); 
+3
source

Source: https://habr.com/ru/post/1265324/


All Articles