mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
fix 权重查询 (#666)
This commit is contained in:
parent
f35a89e401
commit
3d8d0ad107
@ -2,7 +2,7 @@
|
|||||||
package quan
|
package quan
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"encoding/json"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -11,13 +11,18 @@ import (
|
|||||||
"github.com/FloatTech/zbputils/control"
|
"github.com/FloatTech/zbputils/control"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
quan = "http://tc.tfkapi.top/API/qqqz.php?qq=%v" // api
|
quan = "http://tfapi.top/API/qqqz.php?type=json&qq=" // api
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type result struct {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Qz string `json:"qz"`
|
||||||
|
}
|
||||||
|
|
||||||
func init() { // 主函数
|
func init() { // 主函数
|
||||||
en := control.Register("quan", &ctrl.Options[*zero.Ctx]{
|
en := control.Register("quan", &ctrl.Options[*zero.Ctx]{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
@ -31,28 +36,25 @@ func init() { // 主函数
|
|||||||
if str == "" { // user
|
if str == "" { // user
|
||||||
str = strconv.FormatInt(ctx.Event.UserID, 10)
|
str = strconv.FormatInt(ctx.Event.UserID, 10)
|
||||||
}
|
}
|
||||||
es, err := web.GetData(fmt.Sprintf(quan, str)) // 将网站返回结果赋值
|
es, err := web.GetData(quan + str) // 将网站返回结果赋值
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("出现错误捏:", err))
|
ctx.SendChain(message.Text("出现错误捏: ", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(helper.BytesToString(es)) <= 24 {
|
var data result
|
||||||
ctx.SendChain(message.Text("网站维护中")) // 输出结果
|
err = json.Unmarshal(es, &data)
|
||||||
return
|
|
||||||
}
|
|
||||||
f := helper.BytesToString(es)[24:]
|
|
||||||
_, err = strconv.Atoi(f)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("网站维护中")) // 输出结果
|
ctx.SendChain(message.Text("解析json错误: ", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var msg strings.Builder
|
var msg strings.Builder
|
||||||
msg.WriteString("查询账号:")
|
msg.WriteString("查询账号: ")
|
||||||
msg.WriteString(str)
|
msg.WriteString(str)
|
||||||
msg.WriteString("\n")
|
msg.WriteString("\n")
|
||||||
msg.WriteString("查询状态:成功\n")
|
msg.WriteString("查询状态: ")
|
||||||
msg.WriteString("您的权重为:")
|
msg.WriteString(data.Msg)
|
||||||
msg.WriteString(f)
|
msg.WriteString("\n您的权重为: ")
|
||||||
|
msg.WriteString(data.Qz)
|
||||||
ctx.SendChain(message.Text(msg.String())) // 输出结果
|
ctx.SendChain(message.Text(msg.String())) // 输出结果
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user