How to get access_hash from channel_id in a telegram with Tlsharp and C #?

I have a program developed by Tlsharp and I want to join a channel that has channel_id but to connect channels I need channel_id and access_hash for the request TLRequestJoinChannel.

So I need to get access_hash from channel_id .

Can someone help me solve this problem?

+4
source share
2 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)
            {

            }
0
source
   var dialogs = (TLDialogs) await client.GetUserDialogsAsync();

        var channel = dialogs.chats.lists
            .OfType<TLChannel>()
            .FirstOrDefault(c => c.title == "channelName");

             long access_hash = (long) channel.access_hash;
-1
source

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


All Articles