MCPcopy Create free account
hub / github.com/FloatTech/NanoBot-Plugin / init

Function init

plugin/status/main.go:50–81  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48)
49
50func init() { // 插件主体
51 engine := nano.Register("status", &ctrl.Options[*nano.Ctx]{
52 DisableOnDefault: false,
53 Brief: "自检",
54 Help: "- 查询计算机当前活跃度: [检查身体 | 自检 | 启动自检 | 系统状态]",
55 })
56
57 engine.OnMessageFullMatchGroup([]string{"检查身体", "自检", "启动自检", "系统状态"}).SetBlock(true).
58 Handle(func(ctx *nano.Ctx) {
59 now := time.Now().Hour()
60 isday = now > 7 && now < 19
61 bot, err := ctx.GetMyInfo()
62 if err != nil {
63 _, _ = ctx.SendPlainMessage(false, "ERROR: ", err)
64 return
65 }
66 img, err := drawstatus(ctx.State["manager"].(*ctrl.Control[*nano.Ctx]), bot.Avatar, bot.Username)
67 if err != nil {
68 _, _ = ctx.SendPlainMessage(false, "ERROR: ", err)
69 return
70 }
71 sendimg, err := imgfactory.ToBytes(img)
72 if err != nil {
73 _, _ = ctx.SendPlainMessage(false, "ERROR: ", err)
74 return
75 }
76 if _, err := ctx.SendImageBytes(sendimg, false); err != nil {
77 _, _ = ctx.SendPlainMessage(false, "ERROR: ", err)
78 }
79 })
80
81}
82
83func drawstatus(m *ctrl.Control[*nano.Ctx], botavartarurl, botname string) (sendimg image.Image, err error) {
84 diskstate, err := diskstate()

Callers

nothing calls this directly

Calls 1

drawstatusFunction · 0.85

Tested by

no test coverage detected