Skip to content

Instantly share code, notes, and snippets.

@jbek7
Last active February 5, 2019 00:52
Show Gist options
  • Save jbek7/c5fe0247a7fb74754b4ad9b31be3e22a to your computer and use it in GitHub Desktop.
Save jbek7/c5fe0247a7fb74754b4ad9b31be3e22a to your computer and use it in GitHub Desktop.
Telegram Auto Replier
import time
from telethon import sync, TelegramClient, events
# sample API_ID from https://github.com/telegramdesktop/tdesktop/blob/f98fdeab3fb2ba6f55daf8481595f879729d1b84/Telegram/SourceFiles/config.h#L220
# or use your own
api_id =
api_hash = ''
# fill in your own details here
phone = '+yourphone'
username = 'YOUR_USER_NAME'
password = 'YOUR_PASSWORD' # if you have two-step verification enabled
# content of the automatic reply
message = "sorry i'm unavailable"
def main():
# Create the client and connect
client = TelegramClient(username, api_id, api_hash)
client.start(phone)
@client.on(events.NewMessage)
def _(event):
if event.is_private:
event.reply(message)
print(time.asctime(), '-', 'Auto-replying...')
client.run_until_disconnected()
client.disconnect()
print(time.asctime(), '-', 'Stopped!')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment