Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add users to Channel? #781

Closed
mowshon opened this Issue Apr 22, 2018 · 8 comments

Comments

Projects
None yet
5 participants
@mowshon
Copy link

mowshon commented Apr 22, 2018

Hello!

I have a list of usernames @user_one, @user_two and my personal public channel.
How can I add automaticaly users to channel with telethon-api ?

@Lonami

This comment has been minimized.

Copy link
Member

Lonami commented Apr 22, 2018

@mowshon what have you tried?

@mowshon

This comment has been minimized.

Copy link
Author

mowshon commented Apr 22, 2018

@Lonami

from telethon import TelegramClient

api_id = 000000
api_hash = 'c111111111111111111111b'

client = TelegramClient('session_name', api_id, api_hash)
client.start()

user = client.get_entity('user_one')
channel = client.get_entity('my_channel')

# Profit ???

I didn't find some examples of adding users to channel.

@Lonami

This comment has been minimized.

@Lonami Lonami closed this Apr 22, 2018

@mowshon

This comment has been minimized.

Copy link
Author

mowshon commented Apr 22, 2018

@Lonami sorry for silly question))
This is working code for me.

from telethon import TelegramClient
from telethon.tl.functions.channels import InviteToChannelRequest

api_id = 00000
api_hash = 'c11111111111111111111111b'

client = TelegramClient('session_name', api_id, api_hash)
client.start()

user = client.get_entity('user_login')
channel = client.get_entity('your_channel')

# Add users.
result = client(InviteToChannelRequest(
    channel,
    [user]
))
@ImTheDeveloper

This comment has been minimized.

Copy link

ImTheDeveloper commented May 25, 2018

Sorry to comment on a closed issue.

Does anyone know the limit on the number of users that can be added? I'm migrating 6000 users from my current channel to merge with another I own. I've tried batching as well as the full amount but I'm currently sat blocked by Telegram because of such efforts. I can't see anywhere mentioning a limit nor sensible wait time between batches

@mowshon

This comment has been minimized.

Copy link
Author

mowshon commented May 26, 2018

@ImTheDeveloper you need to test. But I think if you will add all users from one account, telegram will block you for some period of time and each time will increase this period.

@ozdav

This comment has been minimized.

Copy link

ozdav commented Nov 19, 2018

@mowshon
I tried same as you did InviteToChannelRequest
But I am getting response
updates = []
users = []
Can you please help me?

@amir1379

This comment has been minimized.

Copy link

amir1379 commented Dec 14, 2018

i have that problem too

@LonamiWebs LonamiWebs locked as resolved and limited conversation to collaborators Dec 14, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.