From 0e5a94fb0c7ada3b74971db8095f17a6fd27a4a7 Mon Sep 17 00:00:00 2001 From: Anish Sane Date: Sun, 8 Nov 2020 21:55:17 +0530 Subject: [PATCH] Added support for LIST as command to perform "ls -l" on the download directory. Also fixed a typo in the documentation where variable names were swapped. --- README.md | 4 ++-- telegram-download-daemon.py | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7646cad..d05166e 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ You need to configure these values: |--------------------------|:-----------------------:|--------------------------------------------------------------|---------------------| | `TELEGRAM_DAEMON_API_ID` | `--api-id` | api_id from https://core.telegram.org/api/obtaining_api_id | | | `TELEGRAM_DAEMON_API_HASH` | `--api-hash` | api_hash from https://core.telegram.org/api/obtaining_api_id | | -| `TELEGRAM_DAEMON_CHANNEL` | `--dest` | Destenation path for downloading files | `/telegram-downloads` | -| `TELEGRAM_DAEMON_DEST` | `--channel` | Channel id to download from it | | +| `TELEGRAM_DAEMON_DEST` | `--dest` | Destenation path for downloading files | `/telegram-downloads` | +| `TELEGRAM_DAEMON_CHANNEL` | `--channel` | Channel id to download from it | | You can define the as Environment Variables, or put them as a commend line arguments, for example: diff --git a/telegram-download-daemon.py b/telegram-download-daemon.py index 978c07f..9b5af3b 100644 --- a/telegram-download-daemon.py +++ b/telegram-download-daemon.py @@ -4,6 +4,7 @@ # You need to install telethon (and cryptg to speed up downloads) from os import getenv +import subprocess from sessionManager import getSession, saveSession @@ -101,6 +102,14 @@ with TelegramClient(getSession(), api_id, api_hash, print(event) + if not event.media and event.message: + command = event.message.message + command = command.lower() + if command == "list": + output = subprocess.run(["ls", "-l", downloadFolder], capture_output=True).stdout + output = output.decode('utf-8') + await log_reply(event, output) + if event.media: filename=getFilename(event) await log_reply(event, f"{filename} added to queue")