This repository has been archived by the owner on Jan 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d09466d
Showing
111 changed files
with
17,324 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/golang:1.10 | ||
|
||
working_directory: /go/src/github.com/dan-v/slack-to-telegram | ||
|
||
steps: | ||
- checkout | ||
|
||
- run: make tools && make zip | ||
|
||
- store_artifacts: | ||
path: artifacts/zips |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
config.toml | ||
artifacts/ | ||
slack-to-telegram |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM golang:1.10 | ||
|
||
WORKDIR /go/src/github.com/dan-v/slack-to-telegram/ | ||
|
||
COPY main.go . | ||
COPY vendor vendor | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . | ||
|
||
FROM alpine:latest | ||
RUN apk --no-cache add ca-certificates | ||
WORKDIR /root/ | ||
COPY --from=0 /go/src/github.com/dan-v/slack-to-telegram/app . | ||
CMD ["./app", "-config", "/config.toml"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Gopkg.toml example | ||
# | ||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md | ||
# for detailed Gopkg.toml documentation. | ||
# | ||
# required = ["github.com/user/thing/cmd/thing"] | ||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project" | ||
# version = "1.0.0" | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project2" | ||
# branch = "dev" | ||
# source = "github.com/myfork/project2" | ||
# | ||
# [[override]] | ||
# name = "github.com/x/y" | ||
# version = "2.4.0" | ||
# | ||
# [prune] | ||
# non-go = false | ||
# go-tests = true | ||
# unused-packages = true | ||
|
||
|
||
[[constraint]] | ||
name = "github.com/BurntSushi/toml" | ||
version = "0.3.0" | ||
|
||
[[constraint]] | ||
name = "github.com/nlopes/slack" | ||
version = "0.2.0" | ||
|
||
[[constraint]] | ||
name = "gopkg.in/telegram-bot-api.v4" | ||
version = "4.6.2" | ||
|
||
[prune] | ||
go-tests = true | ||
unused-packages = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
# modified version of https://gist.github.com/kwilczynski/ab451a357fa59b9377b7d946e557ee79 | ||
SHELL := /bin/bash | ||
|
||
TARGET := slack-to-telegram | ||
VERSION := $(shell cat VERSION) | ||
|
||
OS := darwin linux windows freebsd | ||
ARCH := amd64 | ||
|
||
.PHONY: \ | ||
help \ | ||
default \ | ||
clean \ | ||
clean-artifacts \ | ||
clean-vendor \ | ||
tools \ | ||
deps \ | ||
test \ | ||
coverage \ | ||
vet \ | ||
errors \ | ||
lint \ | ||
fmt \ | ||
env \ | ||
build \ | ||
build-all \ | ||
doc \ | ||
check \ | ||
version | ||
|
||
all: fmt lint vet build-all | ||
|
||
help: | ||
@echo 'Usage: make <OPTIONS> ... <TARGETS>' | ||
@echo '' | ||
@echo 'Available targets are:' | ||
@echo '' | ||
@echo ' help Show this help screen.' | ||
@echo ' clean Remove binaries, artifacts and releases.' | ||
@echo ' clean-artifacts Remove build artifacts only.' | ||
@echo ' clean-vendor Remove content of the vendor directory.' | ||
@echo ' tools Install tools needed by the project.' | ||
@echo ' deps Download and install build time dependencies.' | ||
@echo ' test Run unit tests.' | ||
@echo ' coverage Report code tests coverage.' | ||
@echo ' vet Run go vet.' | ||
@echo ' lint Run golint.' | ||
@echo ' fmt Run go fmt.' | ||
@echo ' env Display Go environment.' | ||
@echo ' build Build project for current platform.' | ||
@echo ' build-all Build project for all supported platforms.' | ||
@echo ' doc Start Go documentation server on port 8080.' | ||
@echo ' check Verify compiled binary.' | ||
@echo ' version Display Go version.' | ||
@echo '' | ||
@echo 'Targets run by default are: imports, fmt, lint, vet, errors and build.' | ||
@echo '' | ||
|
||
print-%: | ||
@echo $* = $($*) | ||
|
||
clean: clean-artifacts | ||
go clean -i ./... | ||
rm -vf $(CURDIR)/coverage.* | ||
|
||
clean-artifacts: | ||
rm -Rf artifacts | ||
|
||
clean-vendor: | ||
find $(CURDIR)/vendor -type d -print0 2>/dev/null | xargs -0 rm -Rf | ||
|
||
clean-all: clean clean-artifacts clean-vendor | ||
|
||
tools: | ||
go get github.com/golang/lint/golint | ||
go get github.com/axw/gocov/gocov | ||
go get github.com/matm/gocov-html | ||
go get github.com/tools/godep | ||
go get github.com/mitchellh/gox | ||
|
||
deps: | ||
dep ensure | ||
|
||
test: | ||
go test -v ./... | ||
|
||
coverage: | ||
gocov test ./... > $(CURDIR)/coverage.out 2>/dev/null | ||
gocov report $(CURDIR)/coverage.out | ||
if test -z "$$CI"; then \ | ||
gocov-html $(CURDIR)/coverage.out > $(CURDIR)/coverage.html; \ | ||
if which open &>/dev/null; then \ | ||
open $(CURDIR)/coverage.html; \ | ||
fi; \ | ||
fi | ||
|
||
vet: | ||
go vet -v ./... | ||
|
||
lint: | ||
golint $(go list ./... | grep -v /vendor/) | ||
|
||
fmt: | ||
go fmt ./... | ||
|
||
env: | ||
@go env | ||
|
||
build: | ||
go build -race -ldflags "-X main.version=$(VERSION)" -v -o "$(TARGET)" . | ||
|
||
build-all: | ||
mkdir -v -p $(CURDIR)/artifacts/$(VERSION) | ||
gox -verbose -ldflags "-X main.version=$(VERSION)" \ | ||
-os "$(OS)" -arch "$(ARCH)" \ | ||
-output "$(CURDIR)/artifacts/$(VERSION)/{{.OS}}/$(TARGET)" . | ||
cp -v -f \ | ||
$(CURDIR)/artifacts/$(VERSION)/$$(go env GOOS)/$(TARGET) . | ||
|
||
doc: | ||
godoc -http=:8080 -index | ||
|
||
check: | ||
@test -x $(CURDIR)/$(TARGET) || exit 1 | ||
if $(CURDIR)/$(TARGET) --version | grep -qF '$(VERSION)'; then \ | ||
echo "$(CURDIR)/$(TARGET): OK"; \ | ||
else \ | ||
exit 1; \ | ||
fi | ||
|
||
version: | ||
@go version | ||
|
||
zip: all | ||
mkdir -p artifacts/zips | ||
zip -r artifacts/zips/slack-to-telegram-osx-${VERSION}.zip artifacts/$(VERSION)/darwin/$(TARGET) | ||
zip -r artifacts/zips/slack-to-telegram-windows-${VERSION}.zip artifacts/$(VERSION)/windows/$(TARGET).exe | ||
zip -r artifacts/zips/slack-to-telegram-linux-${VERSION}.zip artifacts/$(VERSION)/linux/$(TARGET) | ||
zip -r artifacts/zips/slack-to-telegram-freebsd-${VERSION}.zip artifacts/$(VERSION)/freebsd/$(TARGET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
`slack-to-telegram` is a simple way to forward notifications from Slack to Telegram. It uses Slack's [Real Time Messaging API](https://api.slack.com/rtm) to connect to specified accounts and will forward messages through Telegram's [Bot API](https://core.telegram.org/bots/api) to you. | ||
|
||
## Why | ||
I currently run CopperheadOS (https://copperhead.co/android/) on my phone, which does not include any Google apps and services. Slack for Android requires Google Cloud Messaging (GCM) in order to receive notifications. Since Telegram has it's own mechanism for notifications on Android that does not rely on GCM, I decided to use this as a workaround to receive timely Slack notications. | ||
|
||
## Features | ||
* Support for multiple Slack workspaces | ||
* Get notifications for direct messages and @username callouts in channels | ||
|
||
## One Time Initial Setup | ||
* From the Telegram account you want to receive messages on, get your user ID by sending a message to `@get_id_bot` | ||
* Create a telegram bot (https://core.telegram.org/bots#3-how-do-i-create-a-bot) and get the token | ||
* Send a test message from your Telegram account to your bots username | ||
* For each Slack account you want to forward messages, sign into Slack and then go to https://api.slack.com/custom-integrations/legacy-tokens and generate a token | ||
|
||
## Config File | ||
Create a file named config.toml and fill in the details from initial setup above. | ||
|
||
```sh | ||
[telegram] | ||
user = 123456789 | ||
token = "323456789:ABCDE_fB19OHQZUF3FPPPF43PTEEB" | ||
|
||
[[slack]] | ||
name = "workspace #1" | ||
token = "xoxp-xxxxxxx-xxxxxxxx-xxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | ||
|
||
[[slack]] | ||
name = "workspace #2" | ||
token = "xoxp-xxxxxxx-xxxxxxxx-xxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | ||
``` | ||
|
||
## Installation | ||
|
||
### Binaries | ||
The easiest way is to download a pre-built binary from the [GitHub Releases](https://github.com/dan-v/slack-to-telegram/releases) page. | ||
|
||
### Docker | ||
You can also just run it as a docker container. | ||
|
||
```sh | ||
docker run --restart=always -d -v $(pwd)/config.toml:/config.toml vdan/slack-to-telegram:latest | ||
``` | ||
|
||
## Usage | ||
```sh | ||
./slack-to-telegram --config config.toml | ||
``` | ||
|
||
## FAQ | ||
1. <b>Should I use slack-to-telegram?</b> That's up to you. Use at your own risk. | ||
|
||
## Powered by | ||
* Slack API ([nlopes/slack]("https://github.com/nlopes/slack")) | ||
* Telegram Bot API ([telegram-bot-api.v4]("gopkg.in/telegram-bot-api.v4")) | ||
* TOML parser ([BurntSushi/toml]("https://github.com/BurntSushi/toml")) | ||
|
||
## Build From Source | ||
```sh | ||
make tools && make | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[telegram] | ||
user = 123456789 | ||
token = "23456789:ABCDE_fB19OHQZUF3FPPPF43PTEEB" | ||
|
||
[[slack]] | ||
name = "workspace label #1" | ||
token = "xoxp-xxxxxxx-xxxxxxxx-xxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |
Oops, something went wrong.