Add user to channel automatically when user asks
Asked Answered
B

3

17

I want to make a very simple project that does this:

An user (let's call him John) opens a Telegram chat with my bot, and inputs this:

User John: /join channel1

My bot responds adding user 'John' to Channel 'channel1'

That's actually all I want. The problem is that Telegram BOT API does not implement any method to add users to groups. I tried to use telegram-cli but 'chat_add_user' only seems to accept adding user to chats, not to groups.

Is there any way I can add an user to a channel like that? (Without manually doing it) or should I forget about this?

Thank you!

Bizerte answered 24/2, 2017 at 21:30 Comment(0)
T
9

You can invite other users to your channel using:

channels.inviteToChannel#199f3a6c channel:InputChannel users:Vector<InputUser> = Updates;

You can invite several uses at a time, via a list (Vector) of InputUser.

This seems consistent with Telegram Desktop and the mobile clients, which allows you to select multiple contacts and add them to your group.

InputUser is of the form:

inputUser#d8292816 user_id:int access_hash:long = InputUser;
Twyla answered 27/2, 2017 at 16:7 Comment(2)
This solved my problem. I executed channels.inviteToChannel and it sends an invite as expected. I ended up using telegram-cli to actually make the call.Shipe
Please close the question if the problem is solved.Cascarilla
A
16

The bot ability is limited. It can only send and receive messages in a chat conversation and collect some information about other chat participants. It can not start a new conversation or other client functionality.

For automate your task, you should use telegram API. There are some clients such as telegram-cli that use the telegram api and have high level methods.

Other clients:

Alkalinity answered 17/5, 2017 at 7:42 Comment(1)
This solved my problem. I was able to use telegram-cli to execute channels.inviteToChannel.Shipe
T
9

You can invite other users to your channel using:

channels.inviteToChannel#199f3a6c channel:InputChannel users:Vector<InputUser> = Updates;

You can invite several uses at a time, via a list (Vector) of InputUser.

This seems consistent with Telegram Desktop and the mobile clients, which allows you to select multiple contacts and add them to your group.

InputUser is of the form:

inputUser#d8292816 user_id:int access_hash:long = InputUser;
Twyla answered 27/2, 2017 at 16:7 Comment(2)
This solved my problem. I executed channels.inviteToChannel and it sends an invite as expected. I ended up using telegram-cli to actually make the call.Shipe
Please close the question if the problem is solved.Cascarilla
S
4

Short Answer: No

It would be very Bad design for Telegram to Expose Any Way Kind of API or Way To Anonymously Join User to Any Channel.

If You only want to Send Text to Some Group of Peoples Then Possibly Use Firebase database With Hooks to Send Message to Each User when Certain message Happens

Stansbury answered 31/12, 2019 at 21:20 Comment(1)
Turns out that this is also true. I can't figure out the exact rules, but you are right, you can't just add anybody. Otherwise you could write a script that iterates over all the numbers and invites everyone. I can invite SOME people. I guess it's people that I have as a contact or have talked to before or something. Will reply here again if I figure it out. Looks like I'm going to have to find a way to generate unique addresses that people can use to join the group.Shipe

© 2022 - 2024 — McMap. All rights reserved.