💩👌 make lint happy

This commit is contained in:
Kanri 2021-07-02 19:52:30 +08:00
parent 760e6334cd
commit 5bee890980
8 changed files with 28 additions and 27 deletions

View File

@ -19,25 +19,25 @@ func init() { // 插件主体
zero.OnFullMatchGroup([]string{"检查身体", "自检", "启动自检", "系统状态"}, zero.AdminPermission). zero.OnFullMatchGroup([]string{"检查身体", "自检", "启动自检", "系统状态"}, zero.AdminPermission).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text( ctx.SendChain(message.Text(
"* CPU占用率: ", getCpuPercent(), "%\n", "* CPU占用率: ", cpuPercent(), "%\n",
"* RAM占用率: ", getMemPercent(), "%\n", "* RAM占用率: ", memPercent(), "%\n",
"* 硬盘活动率: ", getDiskPercent(), "%", "* 硬盘活动率: ", diskPercent(), "%",
), ),
) )
}) })
} }
func getCpuPercent() float64 { func cpuPercent() float64 {
percent, _ := cpu.Percent(time.Second, false) percent, _ := cpu.Percent(time.Second, false)
return math.Round(percent[0]) return math.Round(percent[0])
} }
func getMemPercent() float64 { func memPercent() float64 {
memInfo, _ := mem.VirtualMemory() memInfo, _ := mem.VirtualMemory()
return math.Round(memInfo.UsedPercent) return math.Round(memInfo.UsedPercent)
} }
func getDiskPercent() float64 { func diskPercent() float64 {
parts, _ := disk.Partitions(true) parts, _ := disk.Partitions(true)
diskInfo, _ := disk.Usage(parts[0].Mountpoint) diskInfo, _ := disk.Usage(parts[0].Mountpoint)
return math.Round(diskInfo.UsedPercent) return math.Round(diskInfo.UsedPercent)

View File

@ -1,3 +1,4 @@
// Package atri
// 本文件基于 https://github.com/Kyomotoi/ATRI // 本文件基于 https://github.com/Kyomotoi/ATRI
// 为 Golang 移植版,语料、素材均来自上述项目 // 为 Golang 移植版,语料、素材均来自上述项目
// 本项目遵守 AGPL v3 协议进行开源 // 本项目遵守 AGPL v3 协议进行开源
@ -12,8 +13,11 @@ import (
) )
var ( var (
PRIO = -1 // ATRI 所有命令的优先级
RES = "https://raw.dihe.moe/Yiwen-Chan/ZeroBot-Plugin/master/plugin_atri/" PRIO = -1
// ATRI 表情的 GitHub 镜像位置
RES = "https://raw.dihe.moe/Yiwen-Chan/ZeroBot-Plugin/master/plugin_atri/"
// ATRI 的总开关
ENABLE = true ENABLE = true
) )
@ -89,8 +93,7 @@ func init() { // 插件主体
zero.OnFullMatchGroup([]string{"中午好", "午安"}, AtriSwitch()).SetBlock(true).SetPriority(PRIO). zero.OnFullMatchGroup([]string{"中午好", "午安"}, AtriSwitch()).SetBlock(true).SetPriority(PRIO).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
now := time.Now().Hour() now := time.Now().Hour()
switch { if now > 11 && now < 15 { // 中午
case now < 6: // 凌晨
ctx.SendChain(randText( ctx.SendChain(randText(
"午安w", "午安w",
"午觉要好好睡哦ATRI会陪伴在你身旁的w", "午觉要好好睡哦ATRI会陪伴在你身旁的w",

View File

@ -2,11 +2,12 @@ package plugin_bilibili
import ( import (
"encoding/json" "encoding/json"
"net/http"
"time"
"github.com/robfig/cron" "github.com/robfig/cron"
zero "github.com/wdvxdr1123/ZeroBot" zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message" "github.com/wdvxdr1123/ZeroBot/message"
"net/http"
"time"
) )
type follower struct { type follower struct {
@ -24,14 +25,14 @@ type follower struct {
func init() { func init() {
zero.OnFullMatch("/开启粉丝日报", zero.AdminPermission). zero.OnFullMatch("/开启粉丝日报", zero.AdminPermission).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
FansDaily(130591566) //群号传进去给下面发信息的函数 FansDaily(130591566) // 群号传进去给下面发信息的函数
}) })
} }
// 定时任务每天晚上最后2分钟执行一次 // 定时任务每天晚上最后2分钟执行一次
func FansDaily(groupID int64) { func FansDaily(groupID int64) {
c := cron.New() c := cron.New()
c.AddFunc("0 58 23 * * ?", func() { fansData(groupID) }) _ = c.AddFunc("0 58 23 * * ?", func() { fansData(groupID) })
c.Start() c.Start()
} }

View File

@ -1,4 +1,5 @@
/* /*
Package plugin_chat
对话插件 example 对话插件 example
*/ */
package plugin_chat package plugin_chat
@ -74,13 +75,11 @@ func init() { // 插件主体
"❄️风速中", "\n", "❄️风速中", "\n",
"群温度 ", AirConditTemp[ctx.Event.GroupID], "℃", "群温度 ", AirConditTemp[ctx.Event.GroupID], "℃",
)) ))
return
} else { } else {
ctx.SendChain(message.Text( ctx.SendChain(message.Text(
"💤", "\n", "💤", "\n",
"群温度 ", AirConditTemp[ctx.Event.GroupID], "℃", "群温度 ", AirConditTemp[ctx.Event.GroupID], "℃",
)) ))
return
} }
}) })
zero.OnFullMatch(`群温度`).SetBlock(true).FirstPriority(). zero.OnFullMatch(`群温度`).SetBlock(true).FirstPriority().
@ -93,13 +92,11 @@ func init() { // 插件主体
"❄️风速中", "\n", "❄️风速中", "\n",
"群温度 ", AirConditTemp[ctx.Event.GroupID], "℃", "群温度 ", AirConditTemp[ctx.Event.GroupID], "℃",
)) ))
return
} else { } else {
ctx.SendChain(message.Text( ctx.SendChain(message.Text(
"💤", "\n", "💤", "\n",
"群温度 ", AirConditTemp[ctx.Event.GroupID], "℃", "群温度 ", AirConditTemp[ctx.Event.GroupID], "℃",
)) ))
return
} }
}) })
} }

View File

@ -70,7 +70,7 @@ func init() {
} }
// 请求api // soutuapi 请求api
func soutuapi(keyword string) *AutoGenerated { func soutuapi(keyword string) *AutoGenerated {
url := "https://api.pixivel.moe/pixiv?type=search&page=0&mode=partial_match_for_tags&word=" + keyword url := "https://api.pixivel.moe/pixiv?type=search&page=0&mode=partial_match_for_tags&word=" + keyword
@ -97,7 +97,7 @@ func soutuapi(keyword string) *AutoGenerated {
return result return result
} }
//从json里的30条数据中随机获取一条返回 // Suiji 从json里的30条数据中随机获取一条返回
func Suiji() int { func Suiji() int {
rand.Seed(time.Now().UnixNano()) rand.Seed(time.Now().UnixNano())
return rand.Intn(30) return rand.Intn(30)

View File

@ -260,7 +260,7 @@ func init() { // 插件主体
if ok { if ok {
t.Enable = false t.Enable = false
delete(*timer.Timers, ti) //避免重复取消 delete(*timer.Timers, ti) //避免重复取消
timer.SaveTimers() _ = timer.SaveTimers()
ctx.Send("取消成功~") ctx.Send("取消成功~")
} else { } else {
ctx.Send("没有这个定时器哦~") ctx.Send("没有这个定时器哦~")

View File

@ -129,7 +129,7 @@ func kugou(keyword string) message.MessageSegment {
// 返回音乐卡片 // 返回音乐卡片
return message.CustomMusic( return message.CustomMusic(
"https://www.kugou.com/song/#hash="+audio.Get("hash").Str+"&album_id="+audio.Get("album_id").Str, "https://www.kugou.com/song/#hash="+audio.Get("hash").Str+"&album_id="+audio.Get("album_id").Str,
strings.Replace(audio.Get("play_backup_url").Str, "\\/", "/", -1), strings.ReplaceAll(audio.Get("play_backup_url").Str, "\\/", "/"),
audio.Get("audio_name").Str, audio.Get("audio_name").Str,
).Add("content", audio.Get("author_name").Str).Add("image", audio.Get("img").Str) ).Add("content", audio.Get("author_name").Str).Add("image", audio.Get("img").Str)
} }
@ -202,7 +202,7 @@ func find(pre string, suf string, str string) string {
if n == -1 { if n == -1 {
n = 0 n = 0
} else { } else {
n = n + len(pre) n += len(pre)
} }
str = str[n:] str = str[n:]
m := strings.Index(str, suf) m := strings.Index(str, suf)

View File

@ -4,7 +4,7 @@
package plugin_runcode package plugin_runcode
import ( import (
"fmt" "errors"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
@ -157,7 +157,7 @@ func init() {
block = message.UnescapeCQCodeText(block) block = message.UnescapeCQCodeText(block)
if block == "help" { if block == "help" {
//输出模板 // 输出模板
ctx.SendChain( ctx.SendChain(
message.Text("> ", ctx.Event.Sender.NickName, " ", language, "-template:\n"), message.Text("> ", ctx.Event.Sender.NickName, " ", language, "-template:\n"),
message.Text( message.Text(
@ -216,7 +216,7 @@ func runCode(code string, runType [2]string) (string, error) {
} }
defer body.Body.Close() defer body.Body.Close()
if body.StatusCode != http.StatusOK { if body.StatusCode != http.StatusOK {
return "", fmt.Errorf("code %d", body.StatusCode) return "", errors.New("code not 200")
} }
res, err := ioutil.ReadAll(body.Body) res, err := ioutil.ReadAll(body.Body)
if err != nil { if err != nil {
@ -225,7 +225,7 @@ func runCode(code string, runType [2]string) (string, error) {
// 结果处理 // 结果处理
content := gjson.ParseBytes(res) content := gjson.ParseBytes(res)
if e := content.Get("errors").Str; e != "\n\n" { if e := content.Get("errors").Str; e != "\n\n" {
return "", fmt.Errorf(cutTooLong(clearNewLineSuffix(e))) return "", errors.New(cutTooLong(clearNewLineSuffix(e)))
} }
output := content.Get("output").Str output := content.Get("output").Str