Created
May 26, 2018 16:13
-
-
Save ihfazhillah/0cecd442431b4edbe9cb4d7d38a21588 to your computer and use it in GitHub Desktop.
intro with telethon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import telethon | |
# lets play first with telethon | |
# create client | |
app_id = '' | |
app_hash = '' # you got this two from my.telegram.org | |
client = telethon.TelegramClient('session-name', app_id, app_hash) | |
client.start() | |
# the start method will ask for your phone number and then ask for otp | |
client.send_message('username', 'hello world') | |
# hope you already created a private channel | |
private_channel_url = 'your private channel url' | |
channel = client.get_entity(private_channel_url) | |
clent.send_message(channel, 'hello world from channel') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment