1
0
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:
wdvxdr 2021-05-30 14:38:08 +08:00
parent 9f7e31766b
commit 19fdd34b7f
No known key found for this signature in database
GPG Key ID: 55FF1414A69CEBA6
2 changed files with 12 additions and 15 deletions

View File

@ -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)
}

View File

@ -122,22 +122,21 @@ 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上报客户端