From 5f3889b10488c7454b44826a3924063dae010a5d Mon Sep 17 00:00:00 2001 From: niko Date: Wed, 16 Nov 2022 16:49:57 +0800 Subject: [PATCH] debug info --- boox.go | 11 ++++++++++- main.go | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/boox.go b/boox.go index a506d04..b7da6a0 100644 --- a/boox.go +++ b/boox.go @@ -480,5 +480,14 @@ func request(r *http.Request, t string) (*http.Response, error) { r.Header.Set("Authorization", "Bearer "+t) } - return http.DefaultClient.Do(r) + resp, err := http.DefaultClient.Do(r) + + if bot.Debug { + rqb, _ := io.ReadAll(r.Body) + rsb, _ := io.ReadAll(resp.Body) + + log.Printf("Endpoint: %s, request: %s,response:%s", r.URL, string(rqb), string(rsb)) + } + + return resp, err } diff --git a/main.go b/main.go index d32a8a6..5eacfd9 100644 --- a/main.go +++ b/main.go @@ -82,6 +82,10 @@ func main() { func handleUpdate(update tgbotapi.Update) { + if update.Message == nil { + return + } + if update.Message.IsCommand() { HandleCommand(update.Message) }