aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.travis.yml18
-rw-r--r--README.md1
-rw-r--r--docker-compose-test.yaml62
-rw-r--r--docker-compose-travis.yaml32
-rw-r--r--docker-compose.yaml40
-rw-r--r--hived/Dockerfile (renamed from Dockerfile)8
-rwxr-xr-xhived/docker-entrypoint.sh (renamed from docker-entrypoint.sh)4
-rw-r--r--hived/go.mod (renamed from go.mod)8
-rw-r--r--hived/go.sum (renamed from go.sum)84
-rw-r--r--hived/hived.go (renamed from hived.go)149
-rw-r--r--makefile14
-rw-r--r--protobuf/telegram.proto22
-rwxr-xr-xrun.sh2
-rwxr-xr-xruntravis.sh2
-rw-r--r--telebot/Dockerfile19
-rwxr-xr-xtelebot/docker-entrypoint.sh6
-rw-r--r--telebot/go.mod11
-rw-r--r--telebot/go.sum150
-rw-r--r--telebot/telebot.go81
19 files changed, 558 insertions, 155 deletions
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index f0314d1..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-language: go
-go:
- - 1.15
-env:
- matrix:
- - DOCKER_COMPOSE_VERSION=1.25.0
- global:
- - secure: JW0y+F2BaxmKH00lv/jfiAo2ezMe383oqhA7PozarjYDrksU/cGKgdUay89STXZrN68p+oOIAaGnVM3SGWoKi0gCuDIZKYVVhhCitctnG13toQkvQda8+ceme8spv6ryicX0f2Kpfoe/2tp0cQo1aU16UZ7Zy6pX0Kok62h3wxm5m7ce0lBCyOJkNmHNNCAPgV9VqwpQLPnJyMh0tLuSQLDnKYV+LmNNL2IHVKpg6HRQh01fHvWWI2W+wGhrX4Yerdlm78rcdMJNISulhyyJxCgW5qWyJuIh+/LWX4fhGtIpLB3XZulIQWhjmBTnxHh2UGHYn4iMbMeZ3zdqewv5XBQv55lFuaERF3j7pVRnC+XFJIE9arVvHM0EMkd05O+CbxnPe2gTMIbxQTbVRPq3WzPzLf6o+MmJE+Gib3mz7beIAUbl+YGB6t+Kfgk16RUJrHINYHFXh/aksSbg7IjZT6gPDbtRxsggJPcqUaa5aaIK8wtJxMFxSs53IVUWk5i1kL/Z2J0ulqohZC+94C5HZJf7hZKJkXdX5OToCt+wRQPPuxS2HNKUtrWaxwae9Baxy4NSBbUoHabqUg+uE0cvY10t53RoyJyDZYEiGv3AyUDqUGUvRIy5iM9WDFFbMpbfMdiJE7oRUxfq+DnHAK4AWNfOlAvdijemK7XL42cm4ds=
- - secure: CcatNUm2YY/aGXouNpPeMpnBneoTGLvDpZ7fttI22ZyGDVBShuxgcaHZ2T6Kh4bf+vNWUhVfFoHR7ODJwOARpr6L0GprEZoIqZb1DFdS1fTygvewlMzC4GeTHXRyCZRDtFpQahnNG1MA+ybFgtMI3osEb279+oNA4Mq1wBBECJ1ZT1aXb02wNLs0DygYjEaFzjPEpmMCFoiHwmT5caohHdMx4BNTDWVQtomyE56MGi0ymuHg8TNMUYTiZGLKhcIR8p0RDqs3qs/539DZtISvGsNQjGegk9YhaE13YyhF0wGRT6mzIH8ArGallr4RRMIazvIt3e9nPL67o+YBFlsvWJXqVWp1yScyerFjNk/KR7WDMYCHzyT3g4qTJAt9HPnvboorteLIMPK4yFWzEtLIMtMnWwnWv2qdqXwMRmxIJ3I/tZEX/WMVWRp07mMZJjjtyc5sM28tQze9BxRiKWMC8GFSoSvwr1BNUJMvJX1YCBSPbpRRG37uF6TkC3n4deM0jdQZen2ihM5IDSC2R5gJYEC8xI9pOsdMsj3OZbhZ2qe+4s8jZrz5kGgY3LQLeqXIDwmeMrJ3wJSsiDhG2YoUdGmro3g5ZEdxuPffAVtqaZB7r7qbn/W25Jptghabn1cH7lAnQ1CTwOlzOBc+8+MiZNVG/YRqDuc4u2vacn8Xhm8=
- - secure: ZhSnKN3JLlAXfK9bTTnqTwYINp5j71ZqYlbPAhRKKl3VuUM1OhrC9iWRmxLj0t6r82u5dS9M7dYJWowwLhqkPSWlI/lYqy+4EYtmn+Qa2r7GrRkMsx/CkdC/C3okumJf9gpaYIpJMr7pkUeWbJd6zh/cGxD426NeAv2r2paiGd2rn+AlD67xDcOhJCqAczOHKjSMKLAVsRU6p7rB6Vie1dvY/FrL+enkjlJfWcaEyA5nWiky34Qz81IxqHKaz/4h9Kg3iVwu60Rh86WHu877AbPVykJS+/bZ+l/2FWI3zduifmpm5okf3YLV9XnYFZXmgD8efQi5b/cy5AdbjdnKtTJ/jiM0Ygbd3YfVc/bWb+unLWcr5/f6xaHUKEAlDSIXX8Mu4a2yrBkiUB99XZ+pqo7tC2Heqzytx0iqVxAeTLTx23Ce0e3gzRMGnSV5TW983W/xTlFmGSvgzAfzr/tZC+4DUcRRf6cSWH/CxxTRWrF8p4XeBfbZudD6629i16K1v8iM8sZvAWg1QnhU1qWIHOkVAkMbwPewLN6MVhc2JRMG0eFTn5EMIK5MpCPot2inY10VfcPnswHBSocVUEjhAQ+RtNQyBk9Oc3BhCckZUctR66IWH9bcXvO5MAqOVrEWxzNf2Kf837TZLLJBX36OKwzZCIhLz3Hx3Pd2/7AD+Qs=
-services:
-- docker
-before_install:
-- docker pull redis:6.2-alpine
-install:
-# - docker build -t hived ./ && docker-compose -f ./docker-compose-travis.yaml up -d
-# - "./test/endpoints.sh"
- - go build
diff --git a/README.md b/README.md
index d79b111..e8a2a93 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,3 @@
-[![Build Status](https://travis-ci.com/terminaldweller/hived.svg?branch=main)](https://travis-ci.com/terminaldweller/hived)
[![Go Report Card](https://goreportcard.com/badge/github.com/terminaldweller/hived)](https://goreportcard.com/report/github.com/terminaldweller/hived)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/1e67ac7026904cddb55ede7097995ad8)](https://www.codacy.com/gh/terminaldweller/hived/dashboard?utm_source=github.com&utm_medium=referral&utm_content=terminaldweller/hived&utm_campaign=Badge_Grade)
diff --git a/docker-compose-test.yaml b/docker-compose-test.yaml
new file mode 100644
index 0000000..afee17a
--- /dev/null
+++ b/docker-compose-test.yaml
@@ -0,0 +1,62 @@
+version: "3.4"
+services:
+ hived:
+ image: hived
+ build:
+ context: ./hived
+ secrets:
+ - ch_api_key
+ - ch_api_secret
+ - tg_bot_token
+ networks:
+ - mainnet
+ - telenet
+ ports:
+ - "8008:8008"
+ depends_on:
+ - redis
+ - telebot
+ entrypoint: ["/hived/docker-entrypoint.sh"]
+ cap_drop:
+ - ALL
+ environment:
+ - SERVER_DEPLOYMENT_TYPE=test
+ telebot:
+ image: telebot
+ build:
+ context: ./telebot
+ secrets:
+ - tg_bot_token
+ networks:
+ - telenet
+ ports:
+ - "9009:8000"
+ entrypoint: ["/telebot/docker-entrypoint.sh"]
+ cap_drop:
+ - ALL
+ environment:
+ - SERVER_DEPLOYMENT_TYPE=test
+ redis:
+ image: redis:6.2-alpine
+ networks:
+ - mainnet
+ ports:
+ - "6379:6379"
+ environment:
+ - ALLOW_EMPTY_PASSWORD=yes
+ volumes:
+ - redis-data:/data/
+networks:
+ mainnet:
+ driver: bridge
+ telenet:
+ driver: bridge
+secrets:
+ tg_bot_token:
+ file: ./tgtoken
+ ch_api_key:
+ file: ./changelly_api_key
+ ch_api_secret:
+ file: ./changelly_api_secret
+volumes:
+ redis-data:
diff --git a/docker-compose-travis.yaml b/docker-compose-travis.yaml
deleted file mode 100644
index a5263e0..0000000
--- a/docker-compose-travis.yaml
+++ /dev/null
@@ -1,32 +0,0 @@
-version: "3.4"
-services:
- hived:
- image: hived
- build:
- context: ./
- networks:
- - hivednet
- restart: unless-stopped
- ports:
- - "8008:8008"
- depends_on:
- - redis
- entrypoint: /hived/hived
- redis:
- image: redis:6.2-alpine
- networks:
- - hivednet
- restart: unless-stopped
- ports:
- - "6379:6379"
- environment:
- - ALLOW_EMPTY_PASSWORD=yes
- volumes:
- - redis-data:/data/
-networks:
- hivednet:
- driver: bridge
- routenet:
- driver: bridge
-volumes:
- redis-data:
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 8a404a1..90ff90d 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -3,32 +3,58 @@ services:
hived:
image: hived
build:
- context: ./
+ context: ./hived
secrets:
- - tg_bot_token
- ch_api_key
- ch_api_secret
+ - tg_bot_token
networks:
- - hivednet
+ - mainnet
+ - telenet
restart: unless-stopped
ports:
- "8008:8008"
depends_on:
- redis
- entrypoint: /hived/docker-entrypoint.sh
+ - telebot
+ entrypoint: ["/hived/docker-entrypoint.sh"]
+ volumes:
+ - /etc/letsencrypt/archive/api.terminaldweller.com/:/certs/
+ cap_drop:
+ - ALL
+ environment:
+ - SERVER_DEPLOYMENT_TYPE=deployment
+ telebot:
+ image: telebot
+ build:
+ context: ./telebot
+ secrets:
+ - tg_bot_token
+ networks:
+ - telenet
+ restart: unless-stopped
+ ports:
+ - "127.0.0.1:9009:8000"
+ entrypoint: ["/telebot/docker-entrypoint.sh"]
+ cap_drop:
+ - ALL
+ environment:
+ - SERVER_DEPLOYMENT_TYPE=deployment
redis:
image: redis:6.2-alpine
networks:
- - hivednet
+ - mainnet
restart: unless-stopped
ports:
- - "6379:6379"
+ - "127.0.0.1:6379:6379"
environment:
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- redis-data:/data/
networks:
- hivednet:
+ mainnet:
+ driver: bridge
+ telenet:
driver: bridge
secrets:
tg_bot_token:
diff --git a/Dockerfile b/hived/Dockerfile
index f43cefe..da91fb7 100644
--- a/Dockerfile
+++ b/hived/Dockerfile
@@ -1,5 +1,4 @@
FROM alpine:3.13 as builder
-
RUN apk update && apk upgrade
RUN apk add go git
COPY go.* /hived/
@@ -7,7 +6,14 @@ RUN cd /hived && go mod download
COPY *.go /hived/
RUN cd /hived && go build
+FROM node:lts-alpine3.13 as certbuilder
+RUN apk add openssl
+WORKDIR /certs
+RUN openssl req -nodes -new -x509 -subj="/C=US/ST=Denial/L=springfield/O=Dis/CN=localhost" -keyout server.key -out server.cert
+
+# FROM gcr.io/distroless/static-debian10
FROM alpine:3.13
+COPY --from=certbuilder /certs /certs
COPY --from=builder /hived/hived /hived/
COPY ./docker-entrypoint.sh /hived/
ENTRYPOINT ["/hived/docker-entrypoint.sh"]
diff --git a/docker-entrypoint.sh b/hived/docker-entrypoint.sh
index 6d88ff1..932c9c9 100755
--- a/docker-entrypoint.sh
+++ b/hived/docker-entrypoint.sh
@@ -1,8 +1,8 @@
#!/usr/bin/env sh
-set -e
+set -ex
export $(cat /run/secrets/tg_bot_token)
export $(cat /run/secrets/ch_api_key)
export $(cat /run/secrets/ch_api_secret)
-"/hived/hived"
+"/hived/hived" "$@"
diff --git a/go.mod b/hived/go.mod
index 5a1a643..f2c87cc 100644
--- a/go.mod
+++ b/hived/go.mod
@@ -1,14 +1,14 @@
-module github.com/terminaldweller/hived
+module hived
-go 1.15
+go 1.17
require (
github.com/Knetic/govaluate v3.0.0+incompatible
github.com/go-redis/redis/v8 v8.6.0
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible
- github.com/golang/protobuf v1.4.2
github.com/gorilla/mux v1.8.0
github.com/rs/zerolog v1.20.0
github.com/technoweenie/multipartstreamer v1.0.1 // indirect
- google.golang.org/protobuf v1.23.0
+ github.com/terminaldweller/grpc v1.0.3
+ google.golang.org/grpc v1.42.0
)
diff --git a/go.sum b/hived/go.sum
index 07ad2bc..b303f1e 100644
--- a/go.sum
+++ b/hived/go.sum
@@ -1,34 +1,67 @@
+cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Knetic/govaluate v3.0.0+incompatible h1:7o6+MAPhYTCF0+fdvoz1xDedhRb4f6s9Tn1Tt7/WTEg=
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
+github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
+github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
+github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
+github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
+github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
+github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
+github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
+github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
+github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
+github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
+github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
+github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
+github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
+github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
+github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-redis/redis/v8 v8.6.0 h1:swqbqOrxaPztsj2Hf1p94M3YAgl7hYEpcw21z299hh8=
github.com/go-redis/redis/v8 v8.6.0/go.mod h1:DQ9q4Rk2HtwkrwVrdgmphoOQDMfpvcd/nHEwRsicg8s=
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible h1:2cauKuaELYAEARXRkq2LrJ0yDDv1rW7+wrTEdVL3uaU=
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible/go.mod h1:qf9acutJ8cwBUhm1bqgz6Bei9/C/c93FPDljKWwsOgM=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
+github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
+github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
+github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
+github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
+github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
+github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
+github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
@@ -43,14 +76,19 @@ github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.20.0 h1:38k9hgtUBdxFwE34yS8rTHmHBa4eN16E4DJlv177LNs=
github.com/rs/zerolog v1.20.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM=
github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog=
+github.com/terminaldweller/grpc v1.0.3 h1:yCRm0HKRD4M87CBmmO5KjkSFRq4X2lzHLJRH1ApzeiE=
+github.com/terminaldweller/grpc v1.0.3/go.mod h1:pYpuXZw8rHZwTABVEVZEfErFr+PyEhAaSrFm7y1yvTo=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.opentelemetry.io/otel v0.17.0 h1:6MKOu8WY4hmfpQ4oQn34u6rYhnf2sWf1LXYO/UFm71U=
go.opentelemetry.io/otel v0.17.0/go.mod h1:Oqtdxmf7UtEvL037ohlgnaYa1h7GtMh0NcSd9eqkC9s=
@@ -60,20 +98,36 @@ go.opentelemetry.io/otel/oteltest v0.17.0 h1:TyAihUowTDLqb4+m5ePAsR71xPJaTBJl4KD
go.opentelemetry.io/otel/oteltest v0.17.0/go.mod h1:JT/LGFxPwpN+nlsTiinSYjdIx3hZIGqHCpChcIZmdoE=
go.opentelemetry.io/otel/trace v0.17.0 h1:SBOj64/GAOyWzs5F680yW1ITIfJkm6cJWL2YAvuL9xY=
go.opentelemetry.io/otel/trace v0.17.0/go.mod h1:bIujpqg6ZL6xUTubIUgziI1jSaUPthmabA/ygf/6Cfg=
+go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
+golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U=
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
+golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -88,6 +142,10 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
+golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
@@ -96,20 +154,46 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
+google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=
+google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
+google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
+google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
+google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
+google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
+google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
+google.golang.org/grpc v1.42.0 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A=
+google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
+google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
+google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
+google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
+google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
+google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
diff --git a/hived.go b/hived/hived.go
index 97e9548..d00f58d 100644
--- a/hived.go
+++ b/hived/hived.go
@@ -5,6 +5,7 @@ import (
"context"
"crypto/hmac"
"crypto/sha512"
+ "crypto/tls"
"encoding/hex"
"encoding/json"
"errors"
@@ -21,58 +22,82 @@ import (
"github.com/Knetic/govaluate"
"github.com/go-redis/redis/v8"
- tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
"github.com/gorilla/mux"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
+ pb "github.com/terminaldweller/grpc/telebot/v1"
+ "google.golang.org/grpc"
)
-var flagPort = flag.String("port", "8008", "determined the port the sercice runs on")
-
-var alertsCheckInterval = flag.Int64("alertinterval", 600., "in seconds, the amount of time between alert checks")
-var redisAddress = flag.String("redisaddress", "redis:6379", "determines the address of the redis instance")
-var redisPassword = flag.String("redispassword", "", "determines the password of the redis db")
-var redisDB = flag.Int64("redisdb", 0, "determines the db number")
-var botChannelID = flag.Int64("botchannelid", 146328407, "determines the channel id the telgram bot should send messages to")
-
-const cryptocomparePriceURL = "https://min-api.cryptocompare.com/data/price?"
-const changellyURL = "https://api.changelly.com"
-const TELEGRAM_BOT_TOKEN_ENV_VAR = "TELEGRAM_BOT_TOKEN"
-const CHANGELLY_API_KEY_ENV_VAR = "CHANGELLY_API_KEY"
-const CHANGELLY_API_SECRET_ENV_VAR = "CHANGELLY_API_SECRET"
+var (
+ flagPort = flag.String("port", "8008", "determined the port the sercice runs on")
+ alertsCheckInterval = flag.Int64("alertinterval", 600., "in seconds, the amount of time between alert checks")
+ redisAddress = flag.String("redisaddress", "redis:6379", "determines the address of the redis instance")
+ redisPassword = flag.String("redispassword", "", "determines the password of the redis db")
+ redisDB = flag.Int64("redisdb", 0, "determines the db number")
+ botChannelID = flag.Int64("botchannelid", 146328407, "determines the channel id the telgram bot should send messages to")
+ rdb *redis.Client
+)
-var rdb *redis.Client
+const (
+ cryptocomparePriceURL = "https://min-api.cryptocompare.com/data/price?"
+ changellyURL = "https://api.changelly.com"
+ TELEGRAM_BOT_TOKEN_ENV_VAR = "TELEGRAM_BOT_TOKEN"
+ CHANGELLY_API_KEY_ENV_VAR = "CHANGELLY_API_KEY"
+ CHANGELLY_API_SECRET_ENV_VAR = "CHANGELLY_API_SECRET"
+ SERVER_DEPLOYMENT_TYPE = "SERVER_DEPLOYMENT_TYPE"
+)
-func runTgBot() {
- // bot := getTgBot()
- token := os.Getenv(TELEGRAM_BOT_TOKEN_ENV_VAR)
- bot, err := tgbotapi.NewBotAPI(token[1 : len(token)-1])
+func sendToTg(address, msg string, channelId int64) {
+ conn, err := grpc.Dial(address, grpc.WithInsecure())
if err != nil {
- log.Error().Err(err)
+ log.Fatal().Err(err)
}
- log.Debug().Msg("authorized on account bot_bloodstalker")
+ defer conn.Close()
+
+ c := pb.NewNotificationServiceClient(conn)
- update := tgbotapi.NewUpdate(0)
- update.Timeout = 60
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second)
+ defer cancel()
- updates, err := bot.GetUpdatesChan(update)
+ r, err := c.Notify(ctx, &pb.NotificationRequest{NotificationText: msg, ChannelId: channelId})
if err != nil {
- log.Error().Err(err)
+ log.Fatal().Err(err)
}
- for update := range updates {
- if update.Message == nil {
- continue
- }
+ log.Info().Msg(fmt.Sprintf("%v", r))
+}
- log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)
+// func runTgBot() {
+// // bot := getTgBot()
+// token := os.Getenv(TELEGRAM_BOT_TOKEN_ENV_VAR)
+// bot, err := tgbotapi.NewBotAPI(token[1 : len(token)-1])
+// if err != nil {
+// log.Error().Err(err)
+// }
+// log.Debug().Msg("authorized on account bot_bloodstalker")
- msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text)
- msg.ReplyToMessageID = update.Message.MessageID
+// update := tgbotapi.NewUpdate(0)
+// update.Timeout = 60
- bot.Send(msg)
- }
-}
+// updates, err := bot.GetUpdatesChan(update)
+// if err != nil {
+// log.Error().Err(err)
+// }
+
+// for update := range updates {
+// if update.Message == nil {
+// continue
+// }
+
+// log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)
+
+// msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text)
+// msg.ReplyToMessageID = update.Message.MessageID
+
+// bot.Send(msg)
+// }
+// }
type priceChanStruct struct {
name string
@@ -348,15 +373,19 @@ func alertManager() {
log.Info().Msg(fmt.Sprintf("result: %v", result))
resultBool = result.(bool)
if resultBool == true {
- // bot := getTgBot()
token := os.Getenv(TELEGRAM_BOT_TOKEN_ENV_VAR)
- bot, err := tgbotapi.NewBotAPI(token[1 : len(token)-1])
+ // bot, err := tgbotapi.NewBotAPI(token[1 : len(token)-1])
+ // if err != nil {
+ // log.Error().Err(err)
+ // }
+ msgText := "notification " + alerts.Alerts[i].Expr + " has been triggered"
+ // msg := tgbotapi.NewMessage(*botChannelID, msgText)
+ // bot.Send(msg)
+ tokenInt, err := strconv.ParseInt(token[1:len(token)-1], 10, 64)
if err != nil {
- log.Error().Err(err)
+ log.Fatal().Err(err)
}
- msgText := "notification " + alerts.Alerts[i].Expr + " has been triggered"
- msg := tgbotapi.NewMessage(*botChannelID, msgText)
- bot.Send(msg)
+ sendToTg("telebot:8000", msgText, tokenInt)
}
}
@@ -394,7 +423,6 @@ func handleAlertPost(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(map[string]interface{}{
"isSuccessful": true,
"error": ""})
-
}
func handleAlertDelete(w http.ResponseWriter, r *http.Request) {
@@ -487,7 +515,6 @@ func alertHandler(w http.ResponseWriter, r *http.Request) {
} else {
http.Error(w, "Method is not supported.", http.StatusNotFound)
}
-
}
func exHandler(w http.ResponseWriter, r *http.Request) {
@@ -601,21 +628,43 @@ func robotsHandler(w http.ResponseWriter, r *http.Request) {
func startServer(gracefulWait time.Duration) {
r := mux.NewRouter()
+ cfg := &tls.Config{
+ MinVersion: tls.VersionTLS13,
+ // CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},
+ // PreferServerCipherSuites: true,
+ // CipherSuites: []uint16{
+ // tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
+ // tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
+ // tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
+ // tls.TLS_RSA_WITH_AES_256_CBC_SHA,
+ // },
+ }
srv := &http.Server{
Addr: "0.0.0.0:" + *flagPort,
WriteTimeout: time.Second * 15,
ReadTimeout: time.Second * 15,
Handler: r,
+ TLSConfig: cfg,
}
- r.HandleFunc("/health", healthHandler)
- r.HandleFunc("/price", priceHandler)
- r.HandleFunc("/pair", pairHandler)
- r.HandleFunc("/alert", alertHandler)
- r.HandleFunc("/ex", exHandler)
- r.HandleFunc("/robots.txt", robotsHandler)
+ r.HandleFunc("/crypto/health", healthHandler)
+ r.HandleFunc("/crypto/price", priceHandler)
+ r.HandleFunc("/crypto/pair", pairHandler)
+ r.HandleFunc("/crypto/alert", alertHandler)
+ r.HandleFunc("/crypto/ex", exHandler)
+ r.HandleFunc("/crypto/robots.txt", robotsHandler)
go func() {
- if err := srv.ListenAndServe(); err != nil {
+ var certPath, keyPath string
+ if os.Getenv(SERVER_DEPLOYMENT_TYPE) == "deployment" {
+ certPath = "/certs/fullchain1.pem"
+ keyPath = "/certs/privkey1.pem"
+ } else if os.Getenv(SERVER_DEPLOYMENT_TYPE) == "test" {
+ certPath = "/certs/server.cert"
+ keyPath = "/certs/server.key"
+ } else {
+ log.Fatal().Err(errors.New(fmt.Sprintf("unknown deployment kind: %s", SERVER_DEPLOYMENT_TYPE)))
+ }
+ if err := srv.ListenAndServeTLS(certPath, keyPath); err != nil {
log.Fatal().Err(err)
}
}()
diff --git a/makefile b/makefile
deleted file mode 100644
index af3354d..0000000
--- a/makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-DST_DIR?=./protobuf
-SRC_DIR?=./protobuf
-PROTOBUF_SRC_LIST:=$(shell find ./protobuf -name '*.proto' )
-ARTIFACT_LIST:=$(patsubst %.proto, %.pb.go, $(shell find ./protobuf -name '*.proto'))
-
-DEFAULT: default
-
-default: $(ARTIFACT_LIST)
-
-$(SRC_DIR)/%.pb.go:$(SRC_DIR)/%.proto
- protoc --proto_path=$(SRC_DIR) --go_out=$(DST_DIR) $<
-
-clean:
- - rm $(ARTIFACT_LIST)
diff --git a/protobuf/telegram.proto b/protobuf/telegram.proto
deleted file mode 100644
index 8a7e6be..0000000
--- a/protobuf/telegram.proto
+++ /dev/null
@@ -1,22 +0,0 @@
-syntax= "proto3";
-package hived;
-
-import "google/protobuf/timestamp.proto";
-option go_package ="../protobuf";
-
-message NotificationRequest {
- reserved 4 to 7;
- string notificationText = 1;
- int64 channel_id = 2;
- google.protobuf.Timestamp request_time = 3;
-}
-
-message NotificationResponse {
- reserved 3 to 6;
- string error = 2;
- bool isOK = 1;
-}
-
-service NotificationService {
- rpc Notify(NotificationRequest) returns (NotificationResponse);
-}
diff --git a/run.sh b/run.sh
deleted file mode 100755
index 4031990..0000000
--- a/run.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/env sh
-docker build -t hived ./ && docker-compose up
diff --git a/runtravis.sh b/runtravis.sh
deleted file mode 100755
index 10ee492..0000000
--- a/runtravis.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/env sh
-
diff --git a/telebot/Dockerfile b/telebot/Dockerfile
new file mode 100644
index 0000000..8259880
--- /dev/null
+++ b/telebot/Dockerfile
@@ -0,0 +1,19 @@
+FROM alpine:3.13 as builder
+RUN apk update && apk upgrade
+RUN apk add go git
+COPY go.* /telebot/
+RUN cd /telebot && go mod download
+COPY *.go /telebot/
+RUN cd /telebot && go build
+
+FROM node:lts-alpine3.13 as certbuilder
+RUN apk add openssl
+WORKDIR /certs
+RUN openssl req -nodes -new -x509 -subj="/C=US/ST=Denial/L=springfield/O=Dis/CN=localhost" -keyout server.key -out server.cert
+
+# FROM gcr.io/distroless/static-debian10
+FROM alpine:3.13
+COPY --from=certbuilder /certs /certs
+COPY --from=builder /telebot/telebot /telebot/
+COPY ./docker-entrypoint.sh /telebot/
+ENTRYPOINT ["/telebot/docker-entrypoint.sh"]
diff --git a/telebot/docker-entrypoint.sh b/telebot/docker-entrypoint.sh
new file mode 100755
index 0000000..c2a6d0a
--- /dev/null
+++ b/telebot/docker-entrypoint.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env sh
+set -ex
+
+export $(cat /run/secrets/tg_bot_token)
+
+"/telebot/telebot" "$@"
diff --git a/telebot/go.mod b/telebot/go.mod
new file mode 100644
index 0000000..d035e69
--- /dev/null
+++ b/telebot/go.mod
@@ -0,0 +1,11 @@
+module telebot
+
+go 1.15
+
+require (
+ github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible
+ github.com/rs/zerolog v1.26.0
+ github.com/technoweenie/multipartstreamer v1.0.1 // indirect
+ github.com/terminaldweller/grpc v1.0.3
+ google.golang.org/grpc v1.42.0
+)
diff --git a/telebot/go.sum b/telebot/go.sum
new file mode 100644
index 0000000..5b1e0a1
--- /dev/null
+++ b/telebot/go.sum
@@ -0,0 +1,150 @@
+cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
+github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
+github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
+github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
+github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
+github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
+github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
+github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
+github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
+github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
+github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
+github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
+github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
+github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
+github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
+github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
+github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible h1:2cauKuaELYAEARXRkq2LrJ0yDDv1rW7+wrTEdVL3uaU=
+github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible/go.mod h1:qf9acutJ8cwBUhm1bqgz6Bei9/C/c93FPDljKWwsOgM=
+github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
+github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
+github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
+github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
+github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
+github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
+github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
+github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
+github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
+github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
+github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
+github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
+github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
+github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
+github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
+github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
+github.com/rs/zerolog v1.26.0 h1:ORM4ibhEZeTeQlCojCK2kPz1ogAY4bGs4tD+SaAdGaE=
+github.com/rs/zerolog v1.26.0/go.mod h1:yBiM87lvSqX8h0Ww4sdzNSkVYZ8dL2xjZJG1lAuGZEo=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM=
+github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog=
+github.com/terminaldweller/grpc v1.0.3 h1:yCRm0HKRD4M87CBmmO5KjkSFRq4X2lzHLJRH1ApzeiE=
+github.com/terminaldweller/grpc v1.0.3/go.mod h1:pYpuXZw8rHZwTABVEVZEfErFr+PyEhAaSrFm7y1yvTo=
+github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
+go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
+golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
+golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d h1:20cMwl2fHAzkJMEA+8J4JgqBQcQGzbisXo31MIeenXI=
+golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
+golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA=
+golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
+golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
+golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
+google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=
+google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
+google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
+google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
+google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
+google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
+google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
+google.golang.org/grpc v1.42.0 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A=
+google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
+google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
+google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
+google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
+google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
+google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
+google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
+google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
+google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
+google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
+google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
+google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
diff --git a/telebot/telebot.go b/telebot/telebot.go
new file mode 100644
index 0000000..0676ce9
--- /dev/null
+++ b/telebot/telebot.go
@@ -0,0 +1,81 @@
+package main
+
+import (
+ "context"
+ "flag"
+ "fmt"
+ "net"
+ "os"
+ "strconv"
+
+ tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
+ "github.com/rs/zerolog/log"
+ pb "github.com/terminaldweller/grpc/telebot/v1"
+ "google.golang.org/grpc"
+)
+
+var (
+ flagPort = flag.String("port", "8000", "determined the port the sercice runs on")
+
+ // FIXME-the client should provide the channel ID
+ botChannelID = flag.Int64("botchannelid", 146328407, "determines the channel id the telgram bot should send messages to")
+)
+
+const (
+ TELEGRAM_BOT_TOKEN_ENV_VAR = "TELEGRAM_BOT_TOKEN"
+ SERVER_DEPLOYMENT_TYPE = "SERVER_DEPLOYMENT_TYPE"
+)
+
+type server struct {
+ pb.UnimplementedNotificationServiceServer
+}
+
+func getTGBot() *tgbotapi.BotAPI {
+ token := os.Getenv(TELEGRAM_BOT_TOKEN_ENV_VAR)
+ bot, err := tgbotapi.NewBotAPI(token[1 : len(token)-1])
+ if err != nil {
+ log.Error().Err(err)
+ }
+ return bot
+}
+
+func sendMessage(bot *tgbotapi.BotAPI, msgText string, channelID int64) error {
+ msg := tgbotapi.NewMessage(channelID, msgText)
+ bot.Send(msg)
+ return nil
+}
+
+func (s *server) Notify(ctx context.Context, NotificationRequest *pb.NotificationRequest) (*pb.NotificationResponse, error) {
+ var err error
+ tgbotapi := getTGBot()
+ if NotificationRequest.ChannelId == 0 {
+ err = sendMessage(tgbotapi, NotificationRequest.NotificationText, *botChannelID)
+ } else {
+ err = sendMessage(tgbotapi, NotificationRequest.NotificationText, NotificationRequest.ChannelId)
+ }
+ if err != nil {
+ return &pb.NotificationResponse{Error: err.Error(), IsOK: false}, err
+ }
+ return &pb.NotificationResponse{Error: "", IsOK: true}, nil
+}
+
+func startServer(port uint16) {
+ listener, err := net.Listen("tcp", fmt.Sprintf("0.0.0.0:%d", port))
+ if err != nil {
+ log.Fatal().Err(err)
+ }
+
+ var opts []grpc.ServerOption
+
+ grpcServer := grpc.NewServer(opts...)
+ pb.RegisterNotificationServiceServer(grpcServer, &server{})
+ if err := grpcServer.Serve(listener); err != nil {
+ log.Fatal().Err(err)
+ }
+}
+
+func main() {
+ flag.Parse()
+ port, _ := strconv.Atoi(*flagPort)
+ startServer(uint16(port))
+}