Skip to content

albertoCCz/aemet_tg_bot

Repository files navigation

AEMET Telegram Bot

This bot has been developed to find new PDF documents in AEMET web pages and send them to the relevant Telegram chats.

Usage

usage: ./aemet_tg_bot <command> [--bot-config=<config-path>]

commands:

help                                 Print this help.
run    --bot-config=<config-path>    Start running the bot.
init   --bot-config=<config-path>    Initialise the registries by running the bot.
                                     Only the error messages to admin chat, if
                                     configured, will be sent.

Quickstart

Using Docker

This option requires having docker installed.

  1. Download the docker image aemet_tg_bot from the package section of this repository.
  2. Set up the bot configuration in the ./botConfig.json file.
  3. Set up the necessary environment variables.
    • Create a file env.list in the root of the project. Inside of it, define the next environment variables.
    • For each Telegram chat/group defined in ./botConfig.json, create a environment variable like <bot-name>_CHAT_ID_<chat-name>. For example, if the bot name is TEST_BOT and the chat name is CHAT_1:
      TEST_BOT_CHAT_ID_CHAT_1="<chat-id>"
    • Define also a variable for the token of the bot. It must follows this convention: BOT_TOKEN_<bot-name>. Following the same example, we would have to define it like this:
      BOT_TOKEN_TEST_BOT="<bot-token>"
  4. (Optionally) Initialise the registries so already uploaded PDFs are not sent to the Telegram groups:
$ docker run --env-file ./env.list aemet_tg_bot
  1. Run the bot
$ docker run --env-file ./env.list aemet_tg_bot run --bot-config=./botConfig.json

Without Docker

This option requires having Go v1.22 installed.

  1. Clone this repository and cd into it:
$ git clone https://github.com/albertoCCz/aemet_tg_bot
$ cd aemet_tg_bot
  1. Download dependencies and build executable.
$ go build
  1. Set up the bot configuration in the ./botConfig.json file. Leave blank the chatId fields and token field, these will be read from the environment variables.
  2. Set up the necessary environment variables.
    • For each Telegram chat/group defined in ./botConfig.json, create a environment variable like <bot-name>_CHAT_ID_<chat-name>. For example, in linux, if the bot name is TEST_BOT and the chat name is CHAT_1:
      $ export TEST_BOT_CHAT_ID_CHAT_1="<chat-id>"
    • Define a variable for the bot token. It must follows this convention: BOT_TOKEN_<bot-name>. Following the same example, we would have to define it like this:
      $ export BOT_TOKEN_TEST_BOT="<bot-token>"
  3. (Optionally) Initialise the registries so already uploaded PDFs are not sent to the Telegram groups:
$ aemet_tg_bot init --bot-config=./botConfig.json
  1. Run the bot
$ aemet_tg_bot run --bot-config=./botConfig.json

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages