mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
style: clean code
This commit is contained in:
parent
9f7e31766b
commit
19fdd34b7f
@ -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)
|
||||
}
|
||||
|
@ -122,23 +122,22 @@ func checkAuth(ctx httpCtx, token string) int {
|
||||
auth := ctx.headerAuth
|
||||
if auth == "" {
|
||||
auth = ctx.query.Get("access_token")
|
||||
} else {
|
||||
authN := strings.SplitN(auth, " ", 2)
|
||||
if len(authN) == 2 {
|
||||
auth = authN[1]
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
default:
|
||||
return http.StatusOK
|
||||
}
|
||||
}
|
||||
|
||||
// RunHTTPServerAndClients 启动HTTP服务器与HTTP上报客户端
|
||||
func RunHTTPServerAndClients(bot *coolq.CQBot, conf *config.HTTPServer) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user