Nukesor / archivebot

:floppy_disk: A telegram bot for backing up and collecting all kinds of media.
MIT License
98 stars 31 forks source link

Support to preview and download via HTTP. #20

Closed sutra closed 4 years ago

sutra commented 4 years ago

And this is a sample nginx conf:

http {
...
    server {
        server_name  www.example.net;
        charset UTF-8;

        location / {
            root   /home/user/archivebot;
            index  index.html index.htm;
        }

        location ~ ^/\d+/ {
            root   /home/user/archivebot;
            autoindex on;
        }

        location ~ ^/archives/\d+/\d+/ {
            root   /home/user/archivebot;
            autoindex on;
        }
...
Nukesor commented 4 years ago

To be honest, I don't think that this is something that should be included into the project.

This doesn't have anything with the bot, since it's a simple nginx file serve configuration.

On top of that, a more safe and ideal config should look something like this:


server {
    listen 443 ssl http2;
    client_max_body_size 10000m;

    server_name {{ nginx_domain }};

    error_log /var/log/nginx/files_error.log;
    access_log /var/log/nginx/files_access.log;

    disable_symlinks off;

    location / {
        auth_basic      "Restricted";
        auth_basic_user_file /etc/nginx/auth_file;

        autoindex on;
        autoindex_exact_size off;
        root {{ path }};
    }
}

This doesn't need any changes to the bot and automatically serves all files with nginx configuration only.

Nukesor commented 4 years ago

Adding http preview/download capabilities can be easily achieved with other and better fitting tools.

There's stuff like nextcloud and droppy, which already offer a full feature set. It doesn't feel right to have this included into the bot, since this also comes with some privacy/security implications.

sutra commented 4 years ago

Actually I need a mechanism to customize the replied message. Maybe some scripts path could be configured, and the scripts accept the variables(such as the ${subscriber.chat_name} and the directory path of the zip files) and return the message to be sent to the Telegram group. And further we can do more in the scripts, such as rsync-ing the zip files to somewhere.

Nukesor commented 4 years ago

So, as far as I understand, you want some kind of customizable callback via templating.

As long is this is encapsulated and purely optional feature, I don't see why this couldn't be added to the project :).

Give the jinja templating engine a look, if you're interested in properly implementing this :)

I would suggest to create a new PR for this feature. This PR will be closed for now, since it's out of scope for this project.