mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 05:30:07 +08:00
fix: 疯狂星期四 API (#1161)
Some checks failed
最新版 / Build binary CI (386, linux) (push) Failing after 1s
最新版 / Build binary CI (386, windows) (push) Failing after 1s
最新版 / Build binary CI (amd64, linux) (push) Failing after 1s
最新版 / Build binary CI (amd64, windows) (push) Failing after 1s
最新版 / Build binary CI (arm, linux) (push) Failing after 1s
最新版 / Build binary CI (arm64, linux) (push) Failing after 1s
PushLint / lint (push) Failing after 1s
打包最新版为 Docker Image / build docker (push) Has been cancelled
Some checks failed
最新版 / Build binary CI (386, linux) (push) Failing after 1s
最新版 / Build binary CI (386, windows) (push) Failing after 1s
最新版 / Build binary CI (amd64, linux) (push) Failing after 1s
最新版 / Build binary CI (amd64, windows) (push) Failing after 1s
最新版 / Build binary CI (arm, linux) (push) Failing after 1s
最新版 / Build binary CI (arm64, linux) (push) Failing after 1s
PushLint / lint (push) Failing after 1s
打包最新版为 Docker Image / build docker (push) Has been cancelled
This commit is contained in:
parent
4151464bdc
commit
39e1f56955
@ -2,7 +2,8 @@
|
||||
package kfccrazythursday
|
||||
|
||||
import (
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
@ -11,9 +12,15 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
crazyURL = "http://api.jixs.cc/api/wenan-fkxqs/index.php"
|
||||
crazyURL = "https://api.pearktrue.cn/api/kfc/"
|
||||
)
|
||||
|
||||
type crazyResponse struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
@ -26,6 +33,18 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(binary.BytesToString(data)))
|
||||
|
||||
var resp crazyResponse
|
||||
if err := json.Unmarshal(data, &resp); err != nil {
|
||||
ctx.SendChain(message.Text("JSON解析失败: ", err))
|
||||
return
|
||||
}
|
||||
|
||||
if resp.Code != 200 {
|
||||
ctx.SendChain(message.Text("API返回错误: ", resp.Msg))
|
||||
return
|
||||
}
|
||||
|
||||
ctx.SendChain(message.Text(resp.Text))
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user