File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed
Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change 22package kfccrazythursday
33
44import (
5- "github.com/FloatTech/floatbox/binary"
5+ "encoding/json"
6+
67 "github.com/FloatTech/floatbox/web"
78 ctrl "github.com/FloatTech/zbpctrl"
89 "github.com/FloatTech/zbputils/control"
@@ -11,9 +12,15 @@ import (
1112)
1213
1314const (
14- crazyURL = "http ://api.jixs.cc /api/wenan-fkxqs/index.php "
15+ crazyURL = "https ://api.pearktrue.cn /api/kfc/ "
1516)
1617
18+ type crazyResponse struct {
19+ Code int `json:"code"`
20+ Msg string `json:"msg"`
21+ Text string `json:"text"`
22+ }
23+
1724func init () {
1825 engine := control .AutoRegister (& ctrl.Options [* zero.Ctx ]{
1926 DisableOnDefault : false ,
@@ -26,6 +33,18 @@ func init() {
2633 ctx .SendChain (message .Text ("ERROR: " , err ))
2734 return
2835 }
29- ctx .SendChain (message .Text (binary .BytesToString (data )))
36+
37+ var resp crazyResponse
38+ if err := json .Unmarshal (data , & resp ); err != nil {
39+ ctx .SendChain (message .Text ("JSON解析失败: " , err ))
40+ return
41+ }
42+
43+ if resp .Code != 200 {
44+ ctx .SendChain (message .Text ("API返回错误: " , resp .Msg ))
45+ return
46+ }
47+
48+ ctx .SendChain (message .Text (resp .Text ))
3049 })
3150}
You can’t perform that action at this time.
0 commit comments