Skip to content

ilbertt/infinitecloud_bot

Repository files navigation

Infinite Cloud Bot

As Telegram offers unlimited cloud storage, it lacks of the main characteristics of the cloud services: folders structure, file names, etc. Here comes the Infinite Cloud Bot! This bot simply keeps track of your files using a json file as the "filesystem", without saving anything outside of the chat and so preserving your privacy.

Usage

Use the bot

Just start a chat with @infinitecloud_bot on Telegram! You'll find more usage instructions at BOT_HELP.md or at /help command in the bot chat.

Run the bot on your server

Prerequisites

Make sure you have Node.js (14.x) and npm installed, you have created a Telegram Bot (instructions) and obtained a Telegram Bot API token.

Install

  1. git clone https://github.com/Luca8991/infinitecloud_bot.git
  2. cd infinitecloud_bot
  3. create a file named .env and add this line inside:
BOT_TOKEN=<your-telegram-bot-api-token>

Run

At this point, you can choose to run it directly on your machine or as a Docker container.

Run directly on your machine:

  1. npm install (to install all dependencies)
  2. run with: node index.js

Run as a Docker container:

Make sure you have Docker and Docker Compose installed on your machine (instructions can be found on Docker docs).

  1. docker-compose up -d --build (to build the image and start the bot)

NOTE: if you're running the container on Raspbian, use this command instead: docker-compose -f docker-compose-raspbian.yaml up -d --build

If you want to shut it down, simply run: docker-compose down.

Use as javascript package

  1. npm install https://github.com/Luca8991/infinitecloud_bot or clone this repo and install locally (npm install /path/to/cloned/repo)
  2. import it:
// other require statements
const {infiniteCloudBot, setBotToken} = require("infinitecloud_bot");
// your code
  1. create a Telegram Bot and get your API token (instructions) and set it before calling any other bot's method:
setBotToken('<your-api-bot-token>');
  1. use infiniteCloudBot class, which is simply a wrapper around telegraf's bot class.

How it works

As mentioned above, the bot keeps track of your files using a "filesystem", which is a json file. To preserve your privacy, the filesystem file is stored ONLY in the chat. As soon as you start the chat, the bot sends you this file, which contains a predefined filesystem that you can change on your needs using the bot commands (/mkdir, /rename_file, /move_file, etc.). Whenever you make a change to the files, the bot fetches the filesystem from the chat, updates it and sends it again to the chat.

Filesystem structure

The filesystem has 2 main elements:

  • Directory, an object with this structure:
Property Description Required
. array of Files yes
"nested-directory-name" Directory no
"another-nested-directory-name" Directory no
...
  • File, an object with this properties:
Property Description Required
name string: name of the file, including its extension yes
messageId number: id of the chat message that contains this file yes
createdAt number: timestamp of when the file was added to the filesystem yes

The entire filesystem is contained inside the Root ("/") directory, whose name isn't editable.


So, an example of a filesystem (as found in initialFilesystem.json file) is:

{
    "/": {
        ".": [
            {
                "name": "thisisafile.txt",
                "messageId": 0,
                "createdAt": 1555555555
            },
            // other files
        ],
        "directory1": {
            ".": [
                // some files
            ],
            "nested_directory1": {
                ".": [
                    {
                        "name": "thisisanotherfile.txt",
                        "messageId": 1,
                        "createdAt": 1555555554
                    },
                    // other files
                ],
                // other nested directories
            },
            "nested_directory2": {
                ".": [
                    // some files
                ],
                // other nested directories
            },
        },
        "directorty2": {
            ".": [],
            // other nested directories
        },
        // other directories
    }
}

Dashboard

There's also a web app available at https://infinitecloud-website-api.web.app/ and hosted on Firebase, where you can view your files (you can't upload or download them from there). Source code available at Luca8991/infinite-cloud-website.

Contribute

If you want to improve this bot, feel free to open issues and/or pull requests.

Let's make this bot better, so that anyone can have free INFINITE cloud storage!