Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the access_hash from channel_id in telegram with Tlsharp and c#?

Tags:

c#

api

telegram

I have a program developed by Tlsharp and I want joining channel that I have its channel_id, but for joining channels I need channel_id and access_hash for TLRequestJoinChannel request.

So I need to get access_hash from channel_id.

Can anybody help me to solve this problem?

like image 385
arash Dman Avatar asked Nov 20 '22 02:11

arash Dman


1 Answers

this code works 100% :-)

var channelInfo = (await client.SendRequestAsync<TeleSharp.TL.Contacts.TLResolvedPeer>(
new TeleSharp.TL.Contacts.TLRequestResolveUsername
{
    username = "ChannelID"
}).ConfigureAwait(false)).chats.lists[0] as TeleSharp.TL.TLChannel;

var Request = new TeleSharp.TL.Channels.TLRequestJoinChannel()
{
    channel = new TLInputChannel
    {
        channel_id = channelInfo.id,
        access_hash = (long) channelInfo.access_hash
    }
};

try
{
    var Respons = await client.SendRequestAsync<Boolean>(Request);
}
catch (exception ex)
{
    // Do stuff
}
like image 106
Mohammad Hamed Sadeghi Avatar answered Dec 28 '22 13:12

Mohammad Hamed Sadeghi