summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-06-21 00:56:29 +0500
committerilotterytea <iltsu@alright.party>2025-06-21 00:56:29 +0500
commit818713ce93b6bde2e7ac04bfaa221c046000369e (patch)
tree3b59f1318788c2d34056c4c25a147d89407f39d0
parentdca304867f33a63f7fe6fe49b84b92e2d642fa0e (diff)
feat: save uploaded file
-rw-r--r--main.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/main.py b/main.py
index 59535a3..d1cf5da 100644
--- a/main.py
+++ b/main.py
@@ -1,5 +1,26 @@
+from os.path import exists
+
+from telegram import Update
+from telegram.ext import ApplicationBuilder, MessageHandler, CallbackContext, filters
+from os import mkdir
+
+async def download_file(update: Update, _: CallbackContext) -> None:
+ if not exists("./temp"):
+ mkdir("./temp")
+
+ if len(update.message.photo) > 0:
+ file_id = update.message.photo[-1]
+ file = await update.get_bot().get_file(file_id)
+ file_path = f"./temp/{file_id.file_unique_id}"
+ await file.download_to_drive(file_path)
+
+ await update.message.reply_text('Saved!')
+
def run():
- print("kill all niggers")
+ print("Starting the bot...")
+ app = ApplicationBuilder().token("xd").build()
+ app.add_handler(MessageHandler(filters.PHOTO, download_file))
+ app.run_polling()
if __name__ == "__main__":
run() \ No newline at end of file