nada formado (1)

This commit is contained in:
Julio Diez de Revenga 2019-10-15 21:06:24 +02:00
parent 4cbd59c188
commit 5c4c85743f

25
main.py
View File

@ -27,22 +27,27 @@ with TelegramClient(sesion, api_id, api_hash, spawn_read_thread=False)).start()
#TODO: selector de conversaciones si el bot no esta inicializado
chat1 = client.get_entity('t.me/lonami')
createNewDump('lonami', chat1)
chat2 = client.get_entity('t.me/lol')
createNewDump('lol', chat2)
chat3 = client.get_entity('t.me/telegram')
createNewDump('telegram', chat3)
chats = (chat1, chat2, chat3)
@client.on.message(events.NewMessage(chats=lonami, incoming = True))
@client.on.message(events.NewMessage(chats=chats, incoming = True))
async def handler(events):
await
def handler(events):
event.get
def createNewDump(name, entity):
#TODO Test si ya existe un dump anterior
#TODO Test si ya existe un dump anterior, si no, dumpear todo lo anterior
fileName = name+"Dump.json"
with open(fileName,"w+") as f:
meta = {'meta':[{
'name': name,
@ -50,3 +55,13 @@ def createNewDump(name, entity):
'creationDate': strftime("%Y-%m-%d %H:%M:%S", gmtime())
}]}
json.dump(meta, f)
def addEntryToDump(name, element):
#TODO Test si existe el dump anterior
fileName = name+"Dump.json"
with open(fileName,"w+") as f:
message = {'mensaje':[{
'element': element,
'Date': strftime("%Y-%m-%d %H:%M:%S", gmtime())
}]}
json.dump(meta, f)