Skip to content

Commit

Permalink
💩👌 make lint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
kanrichan committed Jul 2, 2021
1 parent 760e633 commit 5bee890
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 27 deletions.
12 changes: 6 additions & 6 deletions plugin_ai_false/ai_false.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ func init() { // 插件主体
zero.OnFullMatchGroup([]string{"检查身体", "自检", "启动自检", "系统状态"}, zero.AdminPermission).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text(
"* CPU占用率: ", getCpuPercent(), "%\n",
"* RAM占用率: ", getMemPercent(), "%\n",
"* 硬盘活动率: ", getDiskPercent(), "%",
"* CPU占用率: ", cpuPercent(), "%\n",
"* RAM占用率: ", memPercent(), "%\n",
"* 硬盘活动率: ", diskPercent(), "%",
),
)
})
}

func getCpuPercent() float64 {
func cpuPercent() float64 {
percent, _ := cpu.Percent(time.Second, false)
return math.Round(percent[0])
}

func getMemPercent() float64 {
func memPercent() float64 {
memInfo, _ := mem.VirtualMemory()
return math.Round(memInfo.UsedPercent)
}

func getDiskPercent() float64 {
func diskPercent() float64 {
parts, _ := disk.Partitions(true)
diskInfo, _ := disk.Usage(parts[0].Mountpoint)
return math.Round(diskInfo.UsedPercent)
Expand Down
11 changes: 7 additions & 4 deletions plugin_atri/atri.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package atri
// 本文件基于 https://github.com/Kyomotoi/ATRI
// 为 Golang 移植版,语料、素材均来自上述项目
// 本项目遵守 AGPL v3 协议进行开源
Expand All @@ -12,8 +13,11 @@ import (
)

var (
PRIO = -1
RES = "https://raw.dihe.moe/Yiwen-Chan/ZeroBot-Plugin/master/plugin_atri/"
// ATRI 所有命令的优先级
PRIO = -1
// ATRI 表情的 GitHub 镜像位置
RES = "https://raw.dihe.moe/Yiwen-Chan/ZeroBot-Plugin/master/plugin_atri/"
// ATRI 的总开关
ENABLE = true
)

Expand Down Expand Up @@ -89,8 +93,7 @@ func init() { // 插件主体
zero.OnFullMatchGroup([]string{"中午好", "午安"}, AtriSwitch()).SetBlock(true).SetPriority(PRIO).
Handle(func(ctx *zero.Ctx) {
now := time.Now().Hour()
switch {
case now < 6: // 凌晨
if now > 11 && now < 15 { // 中午
ctx.SendChain(randText(
"午安w",
"午觉要好好睡哦,ATRI会陪伴在你身旁的w",
Expand Down
9 changes: 5 additions & 4 deletions plugin_bilibili/fansDaily.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package plugin_bilibili

import (
"encoding/json"
"net/http"
"time"

"github.com/robfig/cron"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"net/http"
"time"
)

type follower struct {
Expand All @@ -24,14 +25,14 @@ type follower struct {
func init() {
zero.OnFullMatch("/开启粉丝日报", zero.AdminPermission).
Handle(func(ctx *zero.Ctx) {
FansDaily(130591566) //群号传进去给下面发信息的函数
FansDaily(130591566) // 群号传进去给下面发信息的函数
})
}

// 定时任务每天晚上最后2分钟执行一次
func FansDaily(groupID int64) {
c := cron.New()
c.AddFunc("0 58 23 * * ?", func() { fansData(groupID) })
_ = c.AddFunc("0 58 23 * * ?", func() { fansData(groupID) })
c.Start()
}

Expand Down
5 changes: 1 addition & 4 deletions plugin_chat/chat.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
Package plugin_chat
对话插件 example
*/
package plugin_chat
Expand Down Expand Up @@ -74,13 +75,11 @@ func init() { // 插件主体
"❄️风速中", "\n",
"群温度 ", AirConditTemp[ctx.Event.GroupID], "℃",
))
return
} else {
ctx.SendChain(message.Text(
"💤", "\n",
"群温度 ", AirConditTemp[ctx.Event.GroupID], "℃",
))
return
}
})
zero.OnFullMatch(`群温度`).SetBlock(true).FirstPriority().
Expand All @@ -93,13 +92,11 @@ func init() { // 插件主体
"❄️风速中", "\n",
"群温度 ", AirConditTemp[ctx.Event.GroupID], "℃",
))
return
} else {
ctx.SendChain(message.Text(
"💤", "\n",
"群温度 ", AirConditTemp[ctx.Event.GroupID], "℃",
))
return
}
})
}
4 changes: 2 additions & 2 deletions plugin_image_finder/keyword.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func init() {

}

// 请求api
// soutuapi 请求api
func soutuapi(keyword string) *AutoGenerated {

url := "https://api.pixivel.moe/pixiv?type=search&page=0&mode=partial_match_for_tags&word=" + keyword
Expand All @@ -97,7 +97,7 @@ func soutuapi(keyword string) *AutoGenerated {
return result
}

//从json里的30条数据中随机获取一条返回
// Suiji 从json里的30条数据中随机获取一条返回
func Suiji() int {
rand.Seed(time.Now().UnixNano())
return rand.Intn(30)
Expand Down
2 changes: 1 addition & 1 deletion plugin_manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func init() { // 插件主体
if ok {
t.Enable = false
delete(*timer.Timers, ti) //避免重复取消
timer.SaveTimers()
_ = timer.SaveTimers()
ctx.Send("取消成功~")
} else {
ctx.Send("没有这个定时器哦~")
Expand Down
4 changes: 2 additions & 2 deletions plugin_music/selecter.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func kugou(keyword string) message.MessageSegment {
// 返回音乐卡片
return message.CustomMusic(
"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,
).Add("content", audio.Get("author_name").Str).Add("image", audio.Get("img").Str)
}
Expand Down Expand Up @@ -202,7 +202,7 @@ func find(pre string, suf string, str string) string {
if n == -1 {
n = 0
} else {
n = n + len(pre)
n += len(pre)
}
str = str[n:]
m := strings.Index(str, suf)
Expand Down
8 changes: 4 additions & 4 deletions plugin_runcode/code_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package plugin_runcode

import (
"fmt"
"errors"
"io/ioutil"
"net/http"
"net/url"
Expand Down Expand Up @@ -157,7 +157,7 @@ func init() {
block = message.UnescapeCQCodeText(block)

if block == "help" {
//输出模板
// 输出模板
ctx.SendChain(
message.Text("> ", ctx.Event.Sender.NickName, " ", language, "-template:\n"),
message.Text(
Expand Down Expand Up @@ -216,7 +216,7 @@ func runCode(code string, runType [2]string) (string, error) {
}
defer body.Body.Close()
if body.StatusCode != http.StatusOK {
return "", fmt.Errorf("code %d", body.StatusCode)
return "", errors.New("code not 200")
}
res, err := ioutil.ReadAll(body.Body)
if err != nil {
Expand All @@ -225,7 +225,7 @@ func runCode(code string, runType [2]string) (string, error) {
// 结果处理
content := gjson.ParseBytes(res)
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

Expand Down

0 comments on commit 5bee890

Please sign in to comment.