Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maslick/telega
HTTP proxy for sending messages to Telegram group chats
https://github.com/maslick/telega
ci docker go heroku jenkins k8s proxy roskomnadzor telegram telegram-api tls
Last synced: about 3 hours ago
JSON representation
HTTP proxy for sending messages to Telegram group chats
- Host: GitHub
- URL: https://github.com/maslick/telega
- Owner: maslick
- License: mit
- Created: 2019-11-22T15:46:55.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-17T11:12:20.000Z (almost 5 years ago)
- Last Synced: 2024-06-20T22:37:05.710Z (5 months ago)
- Topics: ci, docker, go, heroku, jenkins, k8s, proxy, roskomnadzor, telegram, telegram-api, tls
- Language: Go
- Homepage:
- Size: 84 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# =telega=
HTTP proxy for sending messages to Telegram group chats[![Build Status](https://api.travis-ci.org/maslick/telega.svg)](https://travis-ci.org/maslick/telega)
[![Dockerhub](https://img.shields.io/badge/image%20size-2MB-blue.svg)](https://hub.docker.com/r/maslick/telega)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)## Motivation
As you probably know, ``Telegram`` was blocked by Russian authorities a while ago, meaning one cannot access ``https://api.telegram.org`` from within Russia.The solution is to run a proxy outside of Russia or use VPN. In fact, there are many proxies out [there](https://mtpro.xyz/api/?type=socks) (primarily SOCKS).
Their main disadvantage is these proxies come and go, and you simply don't have control over this process. If you need a stable connection, you would eventually run your own server.This simple ``HTTP`` proxy can be run on any cloud provider e.g. Heroku (free 🍺).
Its primary use-case is sending build ``success`` and ``failure`` notifications from CI (e.g. Jenkins) to a group chat. It can also send messages to individual users. Just that, no more no less 👌.## Features
* Written in Go :heart:
* Lightweight static binary: ~2.3 MB zipped
* Cloud-native friendly: Docker + k8s
* Secure: Basic authentication (optional)## How it works
You simply run ``telega`` server with two env. variables: ``$BOT_TOKEN`` and ``$CHAT_ID``.You get the ``BOT_TOKEN`` while creating your bot via ``@BotFather``.
``CHAT_ID`` is the id of the group (or user) you want to send messages to.After this, fire a ``POST`` request to ``/send`` and provide a simple json:
```json
{ "text": "Hello world!!!" }
```## Installation
```zsh
$ go test
$ go build -ldflags="-s -w"$ go build -ldflags="-s -w" && upx telega
```## Usage
* Without authentication:
```zsh
$ export BOT_TOKEN=1234567890abcdef
$ export CHAT_ID=-12345
$ ./telega
Starting server on port 8080 ...$ curl -s -X POST localhost:8080/send --data "{\"text\": \"Hello world\"}"
$ http POST :8080/send <<< '{"text": "Hi folks!"}'
$ wget -q -O- --post-data="{\"text\":\"Yo, guys\"}" localhost:8080/send
```* With Basic authentication:
```zsh
$ export BOT_TOKEN=1234567890abcdef
$ export CHAT_ID=-12345
$ export USERNAME=maslick
$ export PASSWORD=12345
$ export PORT=4000
$ ./telega
Starting server on port 4000 ...$ curl -s -H "Authorization: Basic bWFzbGljazoxMjM0NQ==" -X POST localhost:4000/send --data "{\"text\": \"Hello world\"}"
$ http -a maslick:12345 POST :4000/send <<< '{"text": "Hi folks!"}'
$ wget --header="Authorization: Basic bWFzbGljazoxMjM0NQ==" -q -O- --post-data="{\"text\":\"Yo, guys\"}" localhost:4000/send
```## Docker
```zsh
$ docker build -t maslick/telega .
$ docker run -d \
-e BOT_TOKEN=1234567890abcdef \
-e CHAT_ID=-12345 \
-p 8081:8080 \
maslick/telega$ docker run -d \
-e BOT_TOKEN=1234567890abcdef \
-e CHAT_ID=-12345 \
-e USERNAME=maslick \
-e PASSWORD=12345 \
-p 8082:8080 \
maslick/telega$ http POST `docker-machine ip default`:8081/send <<< '{"text": "Hi folks!"}'
$ http -a maslick:12345 POST `docker-machine ip default`:8082/send <<< '{"text": "Hi folks!"}'
```## Kubernetes
```zsh
$ kubectl apply -f k8s
$ kubectl set env deploy telega \
BOT_TOKEN=1234567890abcdef \
CHAT_ID=-12345 \
USERNAME=maslick \
PASSWORD=12345
```## Heroku
```zsh
$ git clone https://github.com/maslick/telega.git
$ cd telega$ export HEROKU_APP_NAME=hello-world-app
$ heroku login
$ heroku create $HEROKU_APP_NAME
$ git push heroku master
$ heroku config:set BOT_TOKEN=$BOT_TOKEN
$ heroku config:set CHAT_ID=$CHAT_ID
$ heroku config:set USERNAME=$USERNAME
$ heroku config:set PASSWORD=$PASSWORD
$ open https://$HEROKU_APP_NAME.herokuapp.com/health
```