diff --git a/main.go b/main.go index 3cdab2fe..69ed8aaa 100644 --- a/main.go +++ b/main.go @@ -15,11 +15,11 @@ import ( _ "github.com/FloatTech/ZeroBot-Plugin/plugin_runcode" // 在线运行代码 // 娱乐类 - _ "github.com/FloatTech/ZeroBot-Plugin/plugin_music" // 点歌 - _ "github.com/FloatTech/ZeroBot-Plugin/plugin_shindan" // 测定 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_false" // 服务器监控 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin_music" // 点歌 + _ "github.com/FloatTech/ZeroBot-Plugin/plugin_shindan" // 测定 //_ "github.com/FloatTech/ZeroBot-ACGImage" //简易随机图片 - _ "github.com/FloatTech/ZeroBot-Plugin/plugin_AIfalse" // AIfalse插件 // b站相关 _ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili" // 查询b站用户信息 diff --git a/plugin_AIfalse/AIfalse.go b/plugin_AIfalse/AIfalse.go deleted file mode 100644 index 14d304c3..00000000 --- a/plugin_AIfalse/AIfalse.go +++ /dev/null @@ -1,67 +0,0 @@ -package AIfalse - -import ( - "math/rand" - "time" - "github.com/shirou/gopsutil/cpu" - "github.com/shirou/gopsutil/disk" - "github.com/shirou/gopsutil/mem" - "strconv" - - zero "github.com/wdvxdr1123/ZeroBot" - "github.com/wdvxdr1123/ZeroBot/message" -) - -var ( - PRIO = -1 - RES = "file:///E:/Picture data/" - ENABLE = true -) - - -func GetCpuPercent() float64 { - percent, _:= cpu.Percent(time.Second, false) - return percent[0] -} - -func GetMemPercent() float64 { - memInfo, _ := mem.VirtualMemory() - return memInfo.UsedPercent -} - -func GetDiskPercent() float64 { - parts, _ := disk.Partitions(true) - diskInfo, _ := disk.Usage(parts[0].Mountpoint) - return diskInfo.UsedPercent -} - -func init() { // 插件主体 - zero.OnKeywordGroup([]string{"身体检查","自检","启动自检","系统状态"}, zero.AdminPermission). - Handle(func(ctx *zero.Ctx) { - ctx.SendChain(message.Text( - "人家当前CPU占用率是: ",GetCpuPercent(),"%\n", - "人家当前RAM占用率是: ",GetMemPercent(),"%\n", - "人家当前硬盘活动率是: ", GetDiskPercent(), "%\n", - ), - ) - }) -} - -func randText(text ...string) message.MessageSegment { - length := len(text) - return message.Text(text[rand.Intn(length)]) -} - -func randImage(file ...string) message.MessageSegment { - length := len(file) - return message.Image(RES + file[rand.Intn(length)]) -} - -func randRecord(file ...string) message.MessageSegment { - length := len(file) - return message.Record(RES + file[rand.Intn(length)]) -} -func strToInt(str string) int64 { - val, _ := strconv.ParseInt(str, 10, 64) - return val -} diff --git a/plugin_ai_false/ai_false.go b/plugin_ai_false/ai_false.go new file mode 100644 index 00000000..6effc7be --- /dev/null +++ b/plugin_ai_false/ai_false.go @@ -0,0 +1,40 @@ +package plugin_i_false + +import ( + "time" + + "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/disk" + "github.com/shirou/gopsutil/mem" + + zero "github.com/wdvxdr1123/ZeroBot" + "github.com/wdvxdr1123/ZeroBot/message" +) + +func GetCpuPercent() float64 { + percent, _ := cpu.Percent(time.Second, false) + return percent[0] +} + +func GetMemPercent() float64 { + memInfo, _ := mem.VirtualMemory() + return memInfo.UsedPercent +} + +func GetDiskPercent() float64 { + parts, _ := disk.Partitions(true) + diskInfo, _ := disk.Usage(parts[0].Mountpoint) + return diskInfo.UsedPercent +} + +func init() { // 插件主体 + zero.OnFullMatchGroup([]string{"身体检查", "自检", "启动自检", "系统状态"}, zero.AdminPermission). + Handle(func(ctx *zero.Ctx) { + ctx.SendChain(message.Text( + "人家当前CPU占用率是: ", GetCpuPercent(), "%\n", + "人家当前RAM占用率是: ", GetMemPercent(), "%\n", + "人家当前硬盘活动率是: ", GetDiskPercent(), "%\n", + ), + ) + }) +}