udf / the-tag-bot

@TheTagBot - your personal media search engine on Telegram

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The Tag Bot

@TheTagBot is a Telegram bot that lets you save and retrieve media using your own tags.

Setup

If you want to host your own copy of this bot, here's how:

  1. Get Nix running on your system (preferably use NixOS)

  2. Install Elasticsearch

  3. Copy secrets-example.py to secrets.py and edit the HTTP_PASS variable to a secure password (for example hunter2), this is the password for the Elasticsearch user that the bot will use

  4. Setup security in Elasticsearch by putting the following into $ES_PATH_CONF/elasticsearch.yml:

    xpack.security.enabled: true
    discovery.type: single-node

    Then run (as the same user that Elasticsearch runs as):

    elasticsearch-setup-passwords auto

    Put the generated password for the elastic user in secrets.py:

    HTTP_PASS = '<super secret password that you generated earlier>'
    ADMIN_HTTP_PASS = 'elastic user password here'
  5. Now you can run the bot using nix-shell in the repo root:

    nix-shell shell.nix --run 'python bot.py'
    

    The bot will take care of setting up the Elasticsearch indicies that it needs.

  6. Telethon will prompt for your bot token when you first run the bot, when you move it to a server simply copy the bot.session file to the server.

Config

You can change the limits in constants.py to suit your needs.

Development

When you want to make changes to the index mapping, you have to delete and re-create it with the new settings. The scripts directory has two scripts that can help with this:

  • backup.py makes the index read-only and copies all the documents into a backup index
  • recreate.py deletes and re-creates the index with the settings in settings.json, then copies the documents from the backup (you can run this multiple times after having run backup.py once)

About

@TheTagBot - your personal media search engine on Telegram

License:GNU Affero General Public License v3.0


Languages

Language:Python 98.0%Language:Nix 2.0%