Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
import os
|
| 3 |
+
import zipfile
|
| 4 |
+
from pyrogram import Client
|
| 5 |
+
|
| 6 |
+
session_string = os.getenv("SESSION_STRING")
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
async def main():
|
| 10 |
+
app = Client(
|
| 11 |
+
name="x",
|
| 12 |
+
session_string=session_string
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
await app.start()
|
| 16 |
+
|
| 17 |
+
msg = await app.get_messages("nt123456nt", 60)
|
| 18 |
+
|
| 19 |
+
file_path = await msg.download()
|
| 20 |
+
|
| 21 |
+
print("Downloaded:", file_path)
|
| 22 |
+
|
| 23 |
+
with zipfile.ZipFile(file_path, "r") as z:
|
| 24 |
+
z.extractall("out")
|
| 25 |
+
|
| 26 |
+
print("Extracted to: out")
|
| 27 |
+
|
| 28 |
+
for root, _, files in os.walk("out"):
|
| 29 |
+
for f in files:
|
| 30 |
+
path = os.path.join(root, f)
|
| 31 |
+
print("\n---", f, "---")
|
| 32 |
+
try:
|
| 33 |
+
with open(path, "r") as file:
|
| 34 |
+
print(file.read())
|
| 35 |
+
except:
|
| 36 |
+
print("binary/unreadable")
|
| 37 |
+
|
| 38 |
+
await app.stop()
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
asyncio.run(main())
|