Skip to content

HeCorr/telegram-bot-gateway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Bot Gateway

A simple but fast webhook reverse proxy written in Go that allows you to host multiple Telegram bots in the same HTTP port.

Usage

Running from the pre-built binaries

  • Download the latest binary version for your system and skip to the Running it section below.

Building from source

  1. Make sure you have Go installed (at least v1.16)
  2. Clone the repo
  3. Run go build -o gateway.exe ./src

Running it

  1. Generate a config file (bots.yaml) by running ./gateway.exe -i. The file will look like this:
config:
  # Private key file
  key: bot.key
  # Certificate file
  cert: bot.crt
  # Listen address (ip:port)
  listen: localhost:8443
  # Strict mode, ignore requests not coming from Telegram
  strict: false

bots:
    # Bot name for reference (optional)
  - name: Bot One
    # Gateway endpoint for receiving updates on
    endpoint: /bot1
    # Path that requests will be forwarded to (the bot's webhook URL)
    path: https://localhost:3000/bot
  - name: Bot Two
    endpoint: /bot2
    path: https://localhost:3001/bot
  1. Modify the file to suit your needs
  2. Run the binary: ./gateway.exe

Available arguments

-f string
      Use the specified .yaml file (default "bots.yaml")
-l string
      Listen address (default "localhost:8443")
-c string
      Certificate file for HTTPS
-k string
      Private key file for HTTPS
-i
      Initialize (create) bots.yaml file
-s
      Strict mode - blocks requests not coming from Telegram

Note: Running this behind a proxy or a NAT with Strict mode is not recommended. Try disabling it if you're having issues receiving updates.

TODO

  • Improve logging
  • Add more comments to the code
  • Allow specifying options in the bots.yaml file
  • Improve HTTP client (set proper timeouts, ignore certs, etc)
  • Implement -i (init) flag for generating default bots.yaml file
  • Use goreleaser to automate the building process
  • Improve non-Telegram IP blocking middleware
  • Make the Taskfile actually usable
  • Support JSON config files
  • Auto reload..?

About

A simple but fast webhook reverse proxy that allows you to host multiple Telegram bots in the same HTTP port

Topics

Resources

License

Stars

Watchers

Forks

Languages