commit
b6f48255ef
28
telegram.go
28
telegram.go
@ -32,11 +32,6 @@ func GetBotName(bot *tgbotapi.BotAPI) string {
|
||||
}
|
||||
|
||||
func telegramWebhookHandler(w http.ResponseWriter, r *http.Request, token string) {
|
||||
if config.Debug {
|
||||
var v interface{}
|
||||
json.NewDecoder(r.Body).Decode(&v)
|
||||
logger.Debugf("token: %v mgWebhookHandler: %v", token, v)
|
||||
}
|
||||
b, err := getBotByToken(token)
|
||||
if err != nil {
|
||||
raven.CaptureErrorAndWait(err, nil)
|
||||
@ -74,6 +69,10 @@ func telegramWebhookHandler(w http.ResponseWriter, r *http.Request, token string
|
||||
return
|
||||
}
|
||||
|
||||
if config.Debug {
|
||||
logger.Debugf("telegramWebhookHandler: %v", string(bytes))
|
||||
}
|
||||
|
||||
err = json.Unmarshal(bytes, &update)
|
||||
if err != nil {
|
||||
raven.CaptureErrorAndWait(err, nil)
|
||||
@ -113,7 +112,7 @@ func telegramWebhookHandler(w http.ResponseWriter, r *http.Request, token string
|
||||
}
|
||||
|
||||
if config.Debug {
|
||||
logger.Debugf("Bot: %v, Message: %v, Response: %v", b.ID, snd, data)
|
||||
logger.Debugf("telegramWebhookHandler Type: SendMessage, Bot: %v, Message: %v, Response: %v", b.ID, snd, data)
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,7 +137,7 @@ func telegramWebhookHandler(w http.ResponseWriter, r *http.Request, token string
|
||||
}
|
||||
|
||||
if config.Debug {
|
||||
logger.Debugf("Bot: %v, Message: %v, Response: %v", b.ID, snd, data)
|
||||
logger.Debugf("telegramWebhookHandler Type: UpdateMessage, Bot: %v, Message: %v, Response: %v", b.ID, snd, data)
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,11 +145,6 @@ func telegramWebhookHandler(w http.ResponseWriter, r *http.Request, token string
|
||||
}
|
||||
|
||||
func mgWebhookHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if config.Debug {
|
||||
var v interface{}
|
||||
json.NewDecoder(r.Body).Decode(&v)
|
||||
logger.Debugf("mgWebhookHandler: %v", v)
|
||||
}
|
||||
bytes, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
raven.CaptureErrorAndWait(err, nil)
|
||||
@ -158,6 +152,10 @@ func mgWebhookHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if config.Debug {
|
||||
logger.Debugf("mgWebhookHandler request: %v", string(bytes))
|
||||
}
|
||||
|
||||
var msg v1.WebhookRequest
|
||||
err = json.Unmarshal(bytes, &msg)
|
||||
if err != nil {
|
||||
@ -196,7 +194,7 @@ func mgWebhookHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if config.Debug {
|
||||
logger.Debugf("%v", msg)
|
||||
logger.Debugf("mgWebhookHandler sent %v", msg)
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
@ -213,7 +211,7 @@ func mgWebhookHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if config.Debug {
|
||||
logger.Debugf("%v", msg)
|
||||
logger.Debugf("mgWebhookHandler update %v", msg)
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
@ -230,7 +228,7 @@ func mgWebhookHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if config.Debug {
|
||||
logger.Debugf("%v", msg)
|
||||
logger.Debugf("mgWebhookHandler delete %v", msg)
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
Loading…
Reference in New Issue
Block a user