Skip to content

Instantly share code, notes, and snippets.

@ihfazhillah
Created May 26, 2018 16:13
Show Gist options
  • Save ihfazhillah/0cecd442431b4edbe9cb4d7d38a21588 to your computer and use it in GitHub Desktop.
Save ihfazhillah/0cecd442431b4edbe9cb4d7d38a21588 to your computer and use it in GitHub Desktop.
intro with telethon
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