This commit is contained in:
Julio Diez de Revenga 2019-10-15 17:49:30 +02:00
parent b8e73ee7cd
commit 45898287a9

24
main.py Normal file
View File

@ -0,0 +1,24 @@
import os
import sys
import time
#Gettit with pip bro
from telethon import TelegramClient, events, utils
def get_env(name, message, cast=str):
if name in os.environ:
return os.environ[name]
while True:
value = input(message)
try:
return cast(value)
except ValueError as e:
print(e, file=sys.stderr)
time.sleep(1)
sesion = get_env('TG_SESION', 'Enter your API sesion name: ')
api_id = get_env('TG_API_ID', 'Enter your API ID: ', int)
api_hash = get_env('TG_API_HASH', 'Enter your API hash: ')
# Create and start the client so we can make requests (we don't here)
with TelegramClient(sesion, api_id, api_hash).start() as client: