Telegram bot routing framework

Syfaro 552834b0e5 No need to pass a http.Server to Serve. 2 months ago
serve 552834b0e5 No need to pass a http.Server to Serve. 2 months ago
.gitignore bdea97bd0a Remove bots, save bots in config file. 2 months ago
README.md c8d8f6ff7b Option to ping servers on startup for configuration reasons. 2 months ago
config.go ff59cc5008 Move authentication into middleware, new files for methods. 2 months ago
endpoints.go ff59cc5008 Move authentication into middleware, new files for methods. 2 months ago
main.go c8d8f6ff7b Option to ping servers on startup for configuration reasons. 2 months ago

README.md

rheas

Experimental Telegram bot router.

Each bot listens on a socket, the router passes the request into the correct socket.

As Windows does not support unix sockets, it will not work on that platform.

Environment

  • HTTP_HOST – Host to publically listen for requests on
  • RHEAS_CONFIG – Path to file to store configuration on bots
  • RHEAS_SECRET – Secret used to secure requests to add and remove bots
  • RHEAS_PING – Send a "ping" to each bot on startup to inform them of config and tokens

Usage

Build and run rheas as a typical Go program. Set environment variables to desired values.

token is the Telegram Bot API token provided by Botfather. socket is the path to the socket the bot is listening on.

Add a bot

Send a POST request to /add with the Authentication header set to RHEAS_SECRET and a payload similar to the following:

{
    "token": "123456:somesecretstring",
    "socket": "/tmp/telegram/echobot.sock"
}

Remove a bot

Send a POST request to /remove with the Authentication header set to RHEAS_SECRET and a payload similar to the following:

{
    "token": "123456:somesecretstring"
}

Update bot config

Send a POST request to /update with the Authentication header set to RHEAS_SECRET and a payload similar to the following:

{
    "token": "123456:somesecretstring",
    "config": {
        "key": "value"
    }
}

Note that updating config does not merge previously existing values, it completely overwrites the current items with the new data.