All Projects → muety → Webhook2telegram

muety / Webhook2telegram

Licence: mit
🤖 A simple bot to translate JSON HTTP requests into Telegram push messages

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Webhook2telegram

Telegram.bot.framework
Simple framework for building Telegram bots
Stars: ✭ 73 (-79.55%)
Mutual labels:  chatbot, telegram-bot, telegram
Expressbot
一个可以帮你订阅、查询快递物流、跟你闲聊Telegram机器人
Stars: ✭ 137 (-61.62%)
Mutual labels:  chatbot, telegram-bot, telegram
Cog
Bringing the power of the command line to chat
Stars: ✭ 910 (+154.9%)
Mutual labels:  chatbot, devops, chatops
Poshbot
Powershell-based bot framework
Stars: ✭ 410 (+14.85%)
Mutual labels:  chatbot, devops, chatops
Errbot
Errbot is a chatbot, a daemon that connects to your favorite chat service and bring your tools and some fun into the conversation.
Stars: ✭ 2,605 (+629.69%)
Mutual labels:  chatbot, devops, chatops
Telegram Bot Sdk
🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
Stars: ✭ 2,212 (+519.61%)
Mutual labels:  chatbot, telegram-bot, telegram
Telegram.bot
.NET Client for Telegram Bot API
Stars: ✭ 1,964 (+450.14%)
Mutual labels:  chatbot, telegram-bot, telegram
technopsyna
телеграм бот для техноконфы
Stars: ✭ 16 (-95.52%)
Mutual labels:  telegram, telegram-bot, chatbot
Flottbot
A chatbot framework written in Go. All configurations are made in YAML files, or inside scripts written in your favorite language.
Stars: ✭ 175 (-50.98%)
Mutual labels:  chatbot, telegram, chatops
Java Telegram Bot Tutorial
Java Telegram Bot Tutorial. Feel free to submit issue if you found a mistake.
Stars: ✭ 165 (-53.78%)
Mutual labels:  chatbot, telegram-bot, telegram
Urban Bot
🤖 The universal chatbot library based on React. Write once, launch Telegram, Facebook, Slack, ... every messenger with chatbots
Stars: ✭ 223 (-37.54%)
Mutual labels:  chatbot, telegram-bot, telegram
Python-BlackJackBot
A Telegram bot written in Python to play the game BlackJack alone or with your friends
Stars: ✭ 48 (-86.55%)
Mutual labels:  telegram, telegram-bot, chatbot
aboutmeinfo-telegram-bot
ℹ️ About Me Info Bot: Share your social media and links on Telegram
Stars: ✭ 20 (-94.4%)
Mutual labels:  telegram, telegram-bot
TG-FileStreamBot
Stream Telegram files to web
Stars: ✭ 193 (-45.94%)
Mutual labels:  telegram, telegram-bot
teleGit
Telegram Bot in Python
Stars: ✭ 22 (-93.84%)
Mutual labels:  telegram, telegram-bot
checkmk-telegram-notify
Get alerted by Check_MK via Telegram bash script
Stars: ✭ 28 (-92.16%)
Mutual labels:  telegram, telegram-bot
cv4pve-botgram
Telegram Bot for Proxmox VE
Stars: ✭ 26 (-92.72%)
Mutual labels:  telegram, telegram-bot
nebula8
Open source bot to administer a telegram group with different functionalities and blacklist
Stars: ✭ 21 (-94.12%)
Mutual labels:  telegram, telegram-bot
remoteTelegramShell
control your Linux OS computer through Telegram
Stars: ✭ 73 (-79.55%)
Mutual labels:  telegram, telegram-bot
Cdk Constructs
A collection of higher-level aws cdk constructs: slack-approval-workflow, #slack & msteams notifications, chatops, blue-green-container-deployment, codecommit-backup, OWASP dependency-check, contentful-webhook, github-webhook, stripe-webhook, static-website, pull-request-check, pull-request-approval-rule, codepipeline-merge-action, codepipeline-check-parameter-action...
Stars: ✭ 282 (-21.01%)
Mutual labels:  devops, chatops

webhook2telegram

(formerly telegram-middleman-bot)

Say thanks Coding Activity Go Report Card Security Rating Maintainability Rating Technical Debt Lines of Code

Buy me a coffee


A Telegram Bot to translate simple JSON HTTP requests into Telegram push messages that you will get on your Smartphone, PC or whatever Telegram client you have. Just like Gotify, but without an extra app.

Changelog

2020-12-05

2020-11-01

  • Project was renamed from telegram-middleman-bot to webhook2telegram

2020-04-05

2020-03-26

  • ⚠️ alertmanager inlet was renamed to alertmanager_webhook and its endpoint has changed accordingly
  • Docker support, thanks to luza
  • Integration with Bitbucket, thanks to luza

2020-03-10

  • Major code refactorings
  • Support for Inlets (see below)
  • Integration with Prometheus Alertmanager

2019-11-06

Thanks to contributions by peet1993.

  • Introduced explicit IPv6 support
  • Introduced ability to specify network address to bind to

Why might this be useful?

This is especially useful for developers or sysadmins. Imagine you want some kind of reporting from your application or server, like a daily report including some statistics. You don't want to actively look it up on a website but you want to receive it in a passive fashion. Just like getting an e-mail. But come on, let's be honest. E-Mails are so 2010. And they require your little server-side script to include some SMTP library and connect to a mail server. That's too heavyweight just to get some short information. Personally, I have a Python script running on my server which gathers some statistics from log files and databases and regularly sends me a Telegram message.

If you develop those thoughts further, this could potentially replace any kind of e-mail notifications - be it the message that someone has answered to your forum post, your favorite game is now on sale at Steam, and so on. It's lightweight and easy, unlike e-mails that have way too much overhead.

How to run

Hosted

One option is to simply use the hosted instance running at https://apps.muetsch.io/webhook2telegram. It only allows for a maximum of 240 requests per recipient per day.

Self-hosted

If you want to set this up on your own, do the following. You can either run the bot in long-polling- or webhook mode. For production use the latter option is recommended for various reasons. However, you'll need a server with a static IP and s (self-signed) SSL certificate.

Compile from source

  1. git clone github.com/muety/webhook2telegram
  2. GO111MODULE=on go build
  3. Long-polling mode: ./webhook2telegram -token <YOUR_BOTFATHER_TOKEN>
  4. Webhook mode: ./webhook2telegram -token <YOUR_BOTFATHER_TOKEN> -mode webhook

Using Docker

$ docker volume create webhook2telegram_data
$ docker run -d -p 8080:8080 \
    -v webhook2telegram_data:/srv/data \
    -e "APP_TOKEN=<YOUR_BOTFATHER_TOKEN>" \
    -e "APP_MODE=webhook" \
    --name webhook2telegram \
    n1try/webhook2telegram

💡 It is recommended to either use -useHttps or set up a reverse proxy like nginx or Caddy to handle encryption.

Additional parameters

  • -address (string) – Network address (IPv4) to bind to. Defaults to 127.0.0.1.
  • -address6 (string) – Network address (IPv6) to bind to. Defaults to ::1.
  • -disableIPv6 (bool) – Whether to disable listening on both IPv4 and IPv6 interfaces. Defaults to false.
  • -port (int) – TCP port to listen on. Defaults to 8080.
  • -proxy (string) – Proxy connection string to be used for long-polling mode. Defaults to none.
  • -useHttps (bool) – Whether to use HTTPS. Defaults to false.
  • -certPath (string) – Path of your SSL certificate when using webhook mode with useHttp. Default to none.
  • -keyPath (string) – Path of your private SSL key when using webhook mode with useHttp. Default to none.
  • -dataDir (string) – File system location where to store persistent data. Defaults to ..
  • -blacklist (string) – Path to a user id blacklist file. Defaults to blacklist.txt.
  • -rateLimit (int) – Maximum number of messages to be delivered to each recipient per hour. Defaults to 100.
  • -metrics (bool) – Whether to expose Prometheus metrics under /metrics. Defaults to false.

How to use

  1. You need to get a token from the bot. Send a message with /start to the Webhook2Telegram Bot therefore.
  2. Now you can use that token to make HTTP POST requests to http://localhost:8080/api/messages (replace localhost by the hostname of your server running the bot or mine as shown above) with a body that looks like this.
{
	"recipient_token": "3edf633a-eab0-45ea-9721-16c07bb8f245",
	"text": "*Hello World!* (yes, this is Markdown)",
	"type": "TEXT",
	"origin": "My lonely server script"
}

NOTE: If the field type is omitted then the TEXT type will be used as default, though this is not recommended as this may change in future versions.

More details are available here.

Inlets

Inlets provide a mechanism to pre-process incoming data that comes in a format different from what is normally expected by the bot.

This is especially useful if data is sent by external, third-party applications which you cannot modify.

For instance, you might want to deliver alerts from Prometheus' Alertmanager as Telegram notifications. However, Alertmanager's webhook requests look much different from WH2TG's default input format. To still make them fit, you can write an Inlet to massage the data accordingly.

To directly address an inlet, request http://localhost:8080/api/inlets/<inlet_name>. Note that /api/inlets/default is equivalent to /api/messages.

Following inlets are currently available:

Name Description Status
default Simply passes the request through without any changes
alertmanager_webhook Consumes Alertmanager webhook requests
bitbucket_webhook Accepts Bitbucket webhook requests to notify about a pipeline status change
webmentionio_webhook Accepts Webmention.io webhook requests to notify about a new Webmention of one of your articles

Further documentation about the individual inlets is available here.

Metrics

Fundamental Prometheus metrics are exposed under /metrics, if the -metrics flag gets passed. They include:

  • webhook2telegram_messages_total{origin="string", type="string"}
  • webhook2telegram_requests_total{success="string"}

License

MIT @ Ferdinand Mütsch

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].