aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--go.sum1
-rw-r--r--hived.go10
-rw-r--r--makefile14
-rw-r--r--protobuf/telegram.proto22
5 files changed, 48 insertions, 1 deletions
diff --git a/README.md b/README.md
index d4bf16e..84d45c2 100644
--- a/README.md
+++ b/README.md
@@ -65,3 +65,5 @@ You can find the swagger and postman docs under `/api`.<br/>
* ~~fix `hived -help` crashing~~
* haproxy
* turn the telegram bot into its own microservice
+* update openapi3.0 spec and postman
+* telegram bot's endpoint should be gRPC
diff --git a/go.sum b/go.sum
index 355662a..d86acf5 100644
--- a/go.sum
+++ b/go.sum
@@ -90,6 +90,7 @@ google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ
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.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
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=
diff --git a/hived.go b/hived.go
index b4a7956..759c403 100644
--- a/hived.go
+++ b/hived.go
@@ -21,7 +21,7 @@ import (
"github.com/Knetic/govaluate"
"github.com/go-redis/redis/v8"
- "github.com/go-telegram-bot-api/telegram-bot-api"
+ tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
"github.com/gorilla/mux"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
@@ -591,6 +591,13 @@ func healthHandler(w http.ResponseWriter, r *http.Request) {
}{IsHivedOk: IsHivedOk, HivedError: HivedError, IsRedisOk: IsRedisOk, RedisError: RedisError})
}
+func robotsHandler(w http.ResponseWriter, r *http.Request) {
+ json.NewEncoder(w).Encode(struct {
+ UserAgents string `json:"User-Agents"`
+ Disallow string `json:"Disallow"`
+ }{"*", "/"})
+}
+
func startServer(gracefulWait time.Duration) {
r := mux.NewRouter()
srv := &http.Server{
@@ -604,6 +611,7 @@ func startServer(gracefulWait time.Duration) {
r.HandleFunc("/pair", pairHandler)
r.HandleFunc("/alert", alertHandler)
r.HandleFunc("/ex", exHandler)
+ r.HandleFunc("/robots.txt", robotsHandler)
go func() {
if err := srv.ListenAndServe(); err != nil {
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..af3354d
--- /dev/null
+++ b/makefile
@@ -0,0 +1,14 @@
+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
new file mode 100644
index 0000000..8a7e6be
--- /dev/null
+++ b/protobuf/telegram.proto
@@ -0,0 +1,22 @@
+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);
+}