Skip to content

Instantly share code, notes, and snippets.

@MarcosBL
Created September 24, 2019 23:35
Show Gist options
  • Save MarcosBL/c494373936a08415f08d0380f564f718 to your computer and use it in GitHub Desktop.
Save MarcosBL/c494373936a08415f08d0380f564f718 to your computer and use it in GitHub Desktop.
Fuck you deleting Telegram messages after minutes

USELESS

NO SIRVE DE NADA BORRAR TU HISTORIAL, seguirá en el canal 48 horas, disponible para cualquiera que quiera recuperarlo :P

# NO SIRVE DE NADA BORRAR TU HISTORIAL, seguirá en el canal 48 horas
# disponible para cualquiera que quiera recuperarlo :P
from telethon import TelegramClient, events, sync
from telethon.tl.types import InputChannel, PeerChannel
from telethon.tl.types import Channel
import time
api_id = 'XXXXXX'
api_hash = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
client = TelegramClient('session_name', api_id, api_hash)
client.start()
# BOFHers Chat ID
group = client.get_entity(PeerChannel(-1001415290757))
# Dumpea como un cerdo
messages = client.get_admin_log(group)
print(messages)
# O sé mínimamente ordenado
file1 = open("dump.json","w")
c = 0
m = 0
for event in client.iter_admin_log(group):
if event.deleted_message:
print("Guardando mensaje",c, "(", event.old.id, event.old.date,")")
file1.write(event.old.to_json() + ",")
c+=1
if event.old.media:
m+=1
#print(event.old.media.to_dict()['Document']['id'])
client.download_media(event.old.media, str(event.old.id))
print(" Guardando media", m)
time.sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment