mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-13 05:11:21 +00:00
Config is passed into each module. Remove tendermint/confer
This commit is contained in:
@ -5,7 +5,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/sfreiberg/gotwilio"
|
||||
"github.com/tendermint/tendermint/config"
|
||||
)
|
||||
|
||||
var lastAlertUnix int64 = 0
|
||||
@ -15,16 +14,16 @@ var alertCountSince int = 0
|
||||
func Alert(message string) {
|
||||
log.Error("<!> ALERT <!>\n" + message)
|
||||
now := time.Now().Unix()
|
||||
if now-lastAlertUnix > int64(config.App().GetInt("alert_min_interval")) {
|
||||
message = fmt.Sprintf("%v:%v", config.App().GetString("network"), message)
|
||||
if now-lastAlertUnix > int64(config.GetInt("alert_min_interval")) {
|
||||
message = fmt.Sprintf("%v:%v", config.GetString("network"), message)
|
||||
if alertCountSince > 0 {
|
||||
message = fmt.Sprintf("%v (+%v more since)", message, alertCountSince)
|
||||
alertCountSince = 0
|
||||
}
|
||||
if len(config.App().GetString("alert_twilio_sid")) > 0 {
|
||||
if len(config.GetString("alert_twilio_sid")) > 0 {
|
||||
go sendTwilio(message)
|
||||
}
|
||||
if len(config.App().GetString("alert_email_recipients")) > 0 {
|
||||
if len(config.GetString("alert_email_recipients")) > 0 {
|
||||
go sendEmail(message)
|
||||
}
|
||||
} else {
|
||||
@ -41,8 +40,8 @@ func sendTwilio(message string) {
|
||||
if len(message) > 50 {
|
||||
message = message[:50]
|
||||
}
|
||||
twilio := gotwilio.NewTwilioClient(config.App().GetString("alert_twilio_sid"), config.App().GetString("alert_twilio_token"))
|
||||
res, exp, err := twilio.SendSMS(config.App().GetString("alert_twilio_from"), config.App().GetString("alert_twilio_to"), message, "", "")
|
||||
twilio := gotwilio.NewTwilioClient(config.GetString("alert_twilio_sid"), config.GetString("alert_twilio_token"))
|
||||
res, exp, err := twilio.SendSMS(config.GetString("alert_twilio_from"), config.GetString("alert_twilio_to"), message, "", "")
|
||||
if exp != nil || err != nil {
|
||||
log.Error("sendTwilio error", "res", res, "exp", exp, "error", err)
|
||||
}
|
||||
@ -58,7 +57,7 @@ func sendEmail(message string) {
|
||||
if len(subject) > 80 {
|
||||
subject = subject[:80]
|
||||
}
|
||||
err := SendEmail(subject, message, config.App().GetStringSlice("alert_email_recipients"))
|
||||
err := SendEmail(subject, message, config.GetStringSlice("alert_email_recipients"))
|
||||
if err != nil {
|
||||
log.Error("sendEmail error", "error", err, "message", message)
|
||||
}
|
||||
|
Reference in New Issue
Block a user