nada formado

This commit is contained in:
Julio Diez de Revenga 2019-10-15 20:50:37 +02:00
parent e070fe3781
commit 4cbd59c188
2 changed files with 31 additions and 3 deletions

34
main.py
View File

@ -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:
client.start()
me = client.get_me()
#TODO: selector de conversaciones si el bot no esta inicializado
chat1 = client.get_entity('t.me/lonami')
chat2 = client.get_entity('t.me/lol')
chat3 = client.get_entity('t.me/telegram')
chats = (chat1, chat2, chat3)
@client.on.message(events.NewMessage(chats=lonami, incoming = True))
async def handler(events):
await
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)

0
start.sh Normal file → Executable file
View File