我有一个由Tlsharp开发的程序,我想要加入具有 channel_id 的 channel ,但是要加入 channel ,我需要 channel_id access_hash 用于TLRequestJoinChannel请求。

所以我需要从 channel_id 获得 access_hash

有人可以帮我解决这个问题吗?

最佳答案

此代码有效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
}

关于c# - 如何使用Tlsharp和C#从电报的channel_id中获取access_hash?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42665039/

10-11 16:39