nada formado

Julio Diez de Revenga 3 years ago
parent e070fe3781
commit 4cbd59c188
  1. 34
  2. 0

@ -4,6 +4,7 @@ import time
#Gettit with pip bro
from telethon import TelegramClient, events, utils
import json
def get_env(name, message, cast=str):
if name in os.environ:
@ -19,6 +20,33 @@ 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:
# Create and start the client so we can make requests
with TelegramClient(sesion, api_id, api_hash, spawn_read_thread=False)).start() as client:
me = client.get_me()
#TODO: selector de conversaciones si el bot no esta inicializado
chat1 = client.get_entity('')
chat2 = client.get_entity('')
chat3 = client.get_entity('')
chats = (chat1, chat2, chat3)
@client.on.message(events.NewMessage(chats=lonami, incoming = True))
async def handler(events):
def createNewDump(name, entity):
#TODO Test si ya existe un dump anterior
fileName = name+"Dump.json"
with open(fileName,"w+") as f:
meta = {'meta':[{
'name': name,
'entity': entity,
'creationDate': strftime("%Y-%m-%d %H:%M:%S", gmtime())
json.dump(meta, f)