Last active
February 5, 2019 00:52
-
-
Save jbek7/c5fe0247a7fb74754b4ad9b31be3e22a to your computer and use it in GitHub Desktop.
Telegram Auto Replier
This file contains 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 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