MCPcopy Index your code
hub / github.com/FloatTech/ZeroBot-Plugin / init

Function init

plugin/warframeapi/main.go:19–382  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17)
18
19func init() {
20 eng := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
21 DisableOnDefault: false,
22 Brief: "星际战甲",
23 Help: "- wf时间同步\n" +
24 "- [金星|地球|火卫二]平原时间\n" +
25 "- .wm [物品名称]\n" +
26 "- wf仲裁\n" +
27 "- wf警报\n" +
28 "- wf每日特惠",
29 PrivateDataFolder: "warframeapi",
30 })
31
32 // 获取具体的平原时间, 在触发后, 会启动持续时间按5分钟的时间更新模拟, 以此处理短时间内请求时, 时间不会变化的问题
33 eng.OnSuffix("平原时间").SetBlock(true).
34 Handle(func(ctx *zero.Ctx) {
35 if !gameWorld.hasSync() { // 没有进行同步,就拉取一次服务器状态
36 wfapi, err := newwfapi()
37 if err != nil {
38 ctx.SendChain(message.Text("ERROR: 获取服务器时间失败"))
39 }
40 gameWorld.refresh(&wfapi)
41 }
42 var msg any
43 switch ctx.State["args"].(string) {
44 case "地球", "夜灵":
45 msg = gameWorld.w[0]
46 case "金星", "奥布山谷":
47 msg = gameWorld.w[1]
48 case "魔胎之境", "火卫二", "火卫":
49 msg = gameWorld.w[2]
50 default:
51 msg = "ERROR: 平原不存在"
52 }
53 ctx.SendChain(message.Text(msg))
54 // 是否正在进行同步,没有就开启同步,有就不开启
55 if !gameWorld.hasSync() {
56 if gameWorld.setsync() {
57 go func() {
58 // 30*10=300=5分钟
59 for i := 0; i < 30; i++ {
60 time.Sleep(10 * time.Second)
61 gameWorld.update() // 5分钟内每隔10秒更新一下时间
62 }
63 // 5分钟时间同步结束
64 _ = gameWorld.resetsync()
65 }()
66 }
67 }
68 })
69 eng.OnFullMatch("wf警报").SetBlock(true).
70 Handle(func(ctx *zero.Ctx) {
71 wfapi, err := newwfapi()
72 if err != nil {
73 ctx.SendChain(message.Text("ERROR: ", err))
74 return
75 }
76 // 如果返回的wfapi中, 警报数量>0

Callers

nothing calls this directly

Calls 9

newwfapiFunction · 0.85
newwmFunction · 0.85
getitemnameindexFunction · 0.85
getitemsorderFunction · 0.85
hasSyncMethod · 0.80
refreshMethod · 0.80
setsyncMethod · 0.80
resetsyncMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected