skip to Main Content

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?

2

Answers


  1.    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;
    
    Login or Signup to reply.
  2. 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
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search