Skip to content
This repository has been archived by the owner on May 6, 2023. It is now read-only.

Commit

Permalink
feat(block_fetcher): Add telegram report and use env to handle secret…
Browse files Browse the repository at this point in the history
… key
  • Loading branch information
rpplusplus committed Jun 29, 2019
1 parent fa8ac33 commit 9f69390
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion block_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package main

import (
"fmt"
"net/http"
"net/url"
"os"
"time"
)

Expand All @@ -10,8 +13,16 @@ func haveARest() {
}

func main() {
botKey := os.Getenv("LIBRA_BOT_KEY")
botSecret := os.Getenv("LIBRA_BOT_SECRET")
chatId := os.Getenv("LIBRA_BOT_CHAT_ID")
dbURL := os.Getenv("LIBRA_MYSQL_URL")

telegramURL := fmt.Sprintf("https://api.telegram.org/%s:%s/sendMessage?chat_id=%s&parse_mode=markdown&text=", botKey, botSecret, chatId)
fmt.Println(telegramURL)

rpc := NewLibraRPC(nil)
db := NewDataBaseAdapter("root:test@(127.0.0.1:32773)/libra")
db := NewDataBaseAdapter(dbURL)

db.migration()

Expand All @@ -20,6 +31,8 @@ func main() {
for {
if errCnt > 10 {
fmt.Printf("Max Retry Times")

_, _ = http.Get(telegramURL + url.QueryEscape("libra block fetcher failed 10 times"))
break
}

Expand Down

0 comments on commit 9f69390

Please sign in to comment.