1
0
mirror of https://github.com/fumiama/NanoBot.git synced 2026-06-09 04:30:24 +08:00

feat: add v2 login method

This commit is contained in:
源文雨
2023-11-12 15:56:40 +09:00
parent c9f27c6514
commit 57b0a7c52c
4 changed files with 171 additions and 50 deletions

View File

@@ -17,6 +17,8 @@ const (
StandardAPI = `https://api.sgroup.qq.com`
// SandboxAPI 沙箱环境接口域名
SandboxAPI = `https://sandbox.api.sgroup.qq.com`
// AccessTokenAPI 获取接口凭证的 API
AccessTokenAPI = "https://bots.qq.com/app/getAppAccessToken"
)
var (
@@ -30,7 +32,11 @@ type CodeMessageBase struct {
}
func (bot *Bot) dohttprequest(constructer HTTPRequsetConstructer, ep, contenttype string, ptr any, body io.Reader) error {
req, err := constructer(ep, contenttype, bot.Authorization(), body)
appid := ""
if bot.IsV2() {
appid = bot.AppID
}
req, err := constructer(ep, contenttype, bot.Authorization(), appid, body)
if err != nil {
return errors.Wrap(err, getCallerFuncName())
}