diff --git a/coolq/event.go b/coolq/event.go index c9302a8..d3351b6 100644 --- a/coolq/event.go +++ b/coolq/event.go @@ -2,7 +2,6 @@ package coolq import ( "encoding/hex" - "fmt" "io/ioutil" "path" "strconv" @@ -41,7 +40,6 @@ func (bot *CQBot) privateMessageEvent(c *client.QQClient, m *message.PrivateMess bot.oneWayMsgCache.Store(m.Sender.Uin, "") } id := m.Id - fmt.Println(m) if bot.db != nil { id = bot.InsertPrivateMessage(m) } diff --git a/server/http.go b/server/http.go index dca1484..d37096e 100644 --- a/server/http.go +++ b/server/http.go @@ -122,22 +122,21 @@ func checkAuth(ctx httpCtx, token string) int { auth := ctx.headerAuth if auth == "" { auth = ctx.query.Get("access_token") - switch { - case auth == "": - return http.StatusUnauthorized - case auth != token: - return http.StatusForbidden - } } else { - auth := strings.SplitN(auth, " ", 2) - switch { - case len(auth) != 2 || auth[1] == "": - return http.StatusUnauthorized - case auth[1] != token: - return http.StatusForbidden + authN := strings.SplitN(auth, " ", 2) + if len(authN) == 2 { + auth = authN[1] } } - return http.StatusOK + + switch { + case auth == "": + return http.StatusUnauthorized + case auth != token: + return http.StatusForbidden + default: + return http.StatusOK + } } // RunHTTPServerAndClients 启动HTTP服务器与HTTP上报客户端