How to Receive and download text document from a user in Telegram in C# using the WTelegramClient library?

236 views Asked by At

I have a C# Windows Form program that uses the WTelegramClient library to connect to the telegram API. I need the program to download a text document that has been sent to me by another telegram user (not a bot or channel). To get all the messages between me and the user I have applied this code:

Messages_MessagesBase history = await this.client.Messages_GetHistory(peer);

the "history" variable has an array "Messages" which contains all the messages and "peer" is the InputPeer for the other user.I tried using this code :

await client.DownloadFileAsync();

but this method needs two parameters the first one is : (Document document) and the second is (Stream outputStream). How can get these two parameters?

1

There are 1 answers

0
AliSalehi On

please take a look at this example

basically you need to find the document inside message.media and pass it to the method, and the second parameter can be a FileStream or any type of stream you want