Merge pull request #24 from anishsane/master

Added support for LIST as command to perform "ls -l" on the download dir

Closes #21
This commit is contained in:
Alfonso E.M 2020-11-09 13:45:21 +01:00 committed by GitHub
commit 63ae57eff4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -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:

View file

@ -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")