Skip to content

trumae/telegrambot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

telegrambot

General Pub/Sub Telegram Bot

What is the idea here: a simple bot for telegram. It allows you to send notifications via http and their a brodcast to whoever subscribes a channel.

Users should login 1st, so the bot will not send data to strangers

How it works:

  • Bot will persist sessions and subscriptions on postgres database.
  • An APIKey is set when setting up the service
  • Http request should be sent w X-API-KEY header set, see below.
  • Users call bot
  • User call /login where is the password
  • User can call:
    • /sub to subscribe a channel
    • /unsub to unsubscribe
    • /mysubs to list user own subscriptions
    • /subbers to list all users subscribing a channel
    • /pub will send a message to a channel

In case http requests are received as shown below, they will be forwarded to telegram users

Env

These vars are required to run the service:

  • TBOTKEY: Telegram API Key for the bot
  • DSN postgres database dsn, compatible with pg and gorm
  • APIKEY: This is the apikey http clients should use when sending a notification
  • USERPASS: Password users should give to bot when starting to comunicate

Please refer to: Telegram Bot Notify

for a simple notification lib to be used as companion to this bot.

Sample call

POST https://tbot.digitalcircle.com.br/pub
X-API-KEY: {{xapikey}}

{
    "ch":"a",
    "msg":"FAFA 💀 from api"
}

About

General Pub/Sub Telegram Bot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 95.0%
  • Dockerfile 4.0%
  • Makefile 1.0%