mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-18 20:50:12 +08:00
fix(kfccrazythursday): API解析 (#1184)
Some checks failed
打包最新版为 Docker Image / build docker (push) Has been cancelled
最新版 / Build binary CI (386, linux) (push) Has been cancelled
最新版 / Build binary CI (386, windows) (push) Has been cancelled
最新版 / Build binary CI (amd64, linux) (push) Has been cancelled
最新版 / Build binary CI (amd64, windows) (push) Has been cancelled
最新版 / Build binary CI (arm, linux) (push) Has been cancelled
最新版 / Build binary CI (arm64, linux) (push) Has been cancelled
PushLint / lint (push) Has been cancelled
Some checks failed
打包最新版为 Docker Image / build docker (push) Has been cancelled
最新版 / Build binary CI (386, linux) (push) Has been cancelled
最新版 / Build binary CI (386, windows) (push) Has been cancelled
最新版 / Build binary CI (amd64, linux) (push) Has been cancelled
最新版 / Build binary CI (amd64, windows) (push) Has been cancelled
最新版 / Build binary CI (arm, linux) (push) Has been cancelled
最新版 / Build binary CI (arm64, linux) (push) Has been cancelled
PushLint / lint (push) Has been cancelled
This commit is contained in:
parent
a1621f34a0
commit
b6ddda1d51
@ -2,8 +2,6 @@
|
||||
package kfccrazythursday
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
@ -15,12 +13,6 @@ const (
|
||||
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,
|
||||
@ -34,17 +26,7 @@ func init() {
|
||||
return
|
||||
}
|
||||
|
||||
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))
|
||||
// 根据来源API修改返回方式到直接输出文本
|
||||
ctx.SendChain(message.Text(string(data)))
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user