I use Client.Channels_InviteToChannel
but it asks for access_hash
.
How do I suppose to get access_hash
if I never interacted with bot before ?
Note that I’m admin of channel. Also have bot’s token.
I can do that manually using telegram app.
Dim BotFullUser = Await Client.Users_GetFullUser(New InputUser(BotId, 0))
'FAILS HERE
'TL.RpcException: 400 USER_ID_INVALID
Dim BotUser = New InputUser(BotId, BotFullUser.users.ElementAt(0).Value.access_hash)
Dim Ch = "{channel_id}:{channel_hash}".Split(":")
Await Client.Channels_InviteToChannel(New InputChannel(Long.Parse(Ch(0)), Long.Parse(Ch(1))), BotUser)
Edit: Second attempt:
Dim BotUser = (Await Client.Contacts_ResolveUsername(BotUserName)).User
Dim Ch = "{channel_id}:{channel_hash}".Split(":")
Await Client.Channels_InviteToChannel(New InputChannel(Long.Parse(Ch(0)), Long.Parse(Ch(1))), BotUser)
'FAILS HERE
'TL.RpcException: 400 USER_BOT
2
Answers
This works now. Actually we can't add bot without making admin. So just
Channels_EditAdmin
is enough to invite bot.Thanks @Wizou for help
use Contacts_ResolveUsername to get user structure for your bot