Skip to content

Commit 18def7c

Browse files
committed
💩👌 make lint happy
1 parent 59a731d commit 18def7c

9 files changed

Lines changed: 85 additions & 93 deletions

File tree

control/rule.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ import (
1010
"strings"
1111
"sync"
1212

13-
"github.com/FloatTech/ZeroBot-Plugin/utils/txt2img"
14-
1513
log "github.com/sirupsen/logrus"
1614
zero "github.com/wdvxdr1123/ZeroBot"
1715
"github.com/wdvxdr1123/ZeroBot/extension"
1816
"github.com/wdvxdr1123/ZeroBot/message"
1917
"github.com/wdvxdr1123/ZeroBot/utils/helper"
2018

2119
"github.com/FloatTech/ZeroBot-Plugin/utils/sql"
20+
"github.com/FloatTech/ZeroBot-Plugin/utils/txt2img"
2221
)
2322

2423
var (

plugin_book_review/book_review.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import (
77
"github.com/wdvxdr1123/ZeroBot/message"
88
"github.com/wdvxdr1123/ZeroBot/utils/helper"
99

10-
"github.com/FloatTech/ZeroBot-Plugin/utils/txt2img"
11-
1210
"github.com/FloatTech/ZeroBot-Plugin/control"
11+
"github.com/FloatTech/ZeroBot-Plugin/utils/txt2img"
1312
)
1413

1514
func init() {

plugin_manager/timer/msg.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import (
55
"github.com/wdvxdr1123/ZeroBot/message"
66
)
77

8-
func (ts *Timer) sendmsg(grp int64, ctx *zero.Ctx) {
8+
func (t *Timer) sendmsg(grp int64, ctx *zero.Ctx) {
99
ctx.Event = new(zero.Event)
1010
ctx.Event.GroupID = grp
11-
if ts.URL == "" {
12-
ctx.SendChain(atall, message.Text(ts.Alert))
11+
if t.URL == "" {
12+
ctx.SendChain(atall, message.Text(t.Alert))
1313
} else {
14-
ctx.SendChain(atall, message.Text(ts.Alert), message.Image(ts.URL).Add("cache", "0"))
14+
ctx.SendChain(atall, message.Text(t.Alert), message.Image(t.URL).Add("cache", "0"))
1515
}
1616
}

plugin_manager/timer/parse.go

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@ import (
1414
)
1515

1616
// GetTimerInfo 获得标准化定时字符串
17-
func (ts *Timer) GetTimerInfo() string {
18-
if ts.Cron != "" {
19-
return fmt.Sprintf("[%d]%s", ts.GrpID, ts.Cron)
17+
func (t *Timer) GetTimerInfo() string {
18+
if t.Cron != "" {
19+
return fmt.Sprintf("[%d]%s", t.GrpID, t.Cron)
2020
}
21-
return fmt.Sprintf("[%d]%d月%d日%d周%d:%d", ts.GrpID, ts.Month(), ts.Day(), ts.Week(), ts.Hour(), ts.Minute())
21+
return fmt.Sprintf("[%d]%d月%d日%d周%d:%d", t.GrpID, t.Month(), t.Day(), t.Week(), t.Hour(), t.Minute())
2222
}
2323

2424
// GetTimerID 获得标准化 ID
25-
func (ts *Timer) GetTimerID() uint32 {
26-
key := ts.GetTimerInfo()
25+
func (t *Timer) GetTimerID() uint32 {
26+
key := t.GetTimerInfo()
2727
m := md5.Sum(helper.StringToBytes(key))
2828
return binary.LittleEndian.Uint32(m[:4])
2929
}
3030

3131
// GetFilledCronTimer 获得以cron填充好的ts
3232
func GetFilledCronTimer(croncmd string, alert string, img string, botqq, gid int64) *Timer {
33-
var ts Timer
34-
ts.Alert = alert
35-
ts.Cron = croncmd
36-
ts.URL = img
37-
ts.SelfID = botqq
38-
ts.GrpID = gid
39-
return &ts
33+
var t Timer
34+
t.Alert = alert
35+
t.Cron = croncmd
36+
t.URL = img
37+
t.SelfID = botqq
38+
t.GrpID = gid
39+
return &t
4040
}
4141

4242
// GetFilledTimer 获得填充好的ts
@@ -46,79 +46,79 @@ func GetFilledTimer(dateStrs []string, botqq, grp int64, matchDateOnly bool) *Ti
4646
hourStr := []rune(dateStrs[3])
4747
minuteStr := []rune(dateStrs[4])
4848

49-
var ts Timer
49+
var t Timer
5050
mon := time.Month(chineseNum2Int(monthStr))
5151
if (mon != -1 && mon <= 0) || mon > 12 { // 月份非法
52-
ts.Alert = "月份非法!"
53-
return &ts
52+
t.Alert = "月份非法!"
53+
return &t
5454
}
55-
ts.SetMonth(mon)
55+
t.SetMonth(mon)
5656
lenOfDW := len(dayWeekStr)
5757
switch {
5858
case lenOfDW == 4: // 包括末尾的"日"
5959
dayWeekStr = []rune{dayWeekStr[0], dayWeekStr[2]} // 去除中间的十
6060
d := chineseNum2Int(dayWeekStr)
6161
if (d != -1 && d <= 0) || d > 31 { // 日期非法
62-
ts.Alert = "日期非法1!"
63-
return &ts
62+
t.Alert = "日期非法1!"
63+
return &t
6464
}
65-
ts.SetDay(d)
65+
t.SetDay(d)
6666
case dayWeekStr[lenOfDW-1] == rune('日'): // xx日
6767
dayWeekStr = dayWeekStr[:lenOfDW-1]
6868
d := chineseNum2Int(dayWeekStr)
6969
if (d != -1 && d <= 0) || d > 31 { // 日期非法
70-
ts.Alert = "日期非法2!"
71-
return &ts
70+
t.Alert = "日期非法2!"
71+
return &t
7272
}
73-
ts.SetDay(d)
73+
t.SetDay(d)
7474
case dayWeekStr[0] == rune('每'): // 每周
75-
ts.SetWeek(-1)
75+
t.SetWeek(-1)
7676
default: // 周x
7777
w := chineseNum2Int(dayWeekStr[1:])
7878
if w == 7 { // 周天是0
7979
w = 0
8080
}
8181
if w < 0 || w > 6 { // 星期非法
82-
ts.Alert = "星期非法!"
83-
return &ts
82+
t.Alert = "星期非法!"
83+
return &t
8484
}
85-
ts.SetWeek(time.Weekday(w))
85+
t.SetWeek(time.Weekday(w))
8686
}
8787
if len(hourStr) == 3 {
8888
hourStr = []rune{hourStr[0], hourStr[2]} // 去除中间的十
8989
}
9090
h := chineseNum2Int(hourStr)
9191
if h < -1 || h > 23 { // 小时非法
92-
ts.Alert = "小时非法!"
93-
return &ts
92+
t.Alert = "小时非法!"
93+
return &t
9494
}
95-
ts.SetHour(h)
95+
t.SetHour(h)
9696
if len(minuteStr) == 3 {
9797
minuteStr = []rune{minuteStr[0], minuteStr[2]} // 去除中间的十
9898
}
9999
min := chineseNum2Int(minuteStr)
100100
if min < -1 || min > 59 { // 分钟非法
101-
ts.Alert = "分钟非法!"
102-
return &ts
101+
t.Alert = "分钟非法!"
102+
return &t
103103
}
104-
ts.SetMinute(min)
104+
t.SetMinute(min)
105105
if !matchDateOnly {
106106
urlStr := dateStrs[5]
107107
if urlStr != "" { // 是图片url
108-
ts.URL = urlStr[3:] // utf-8下用为3字节
109-
logrus.Println("[群管]" + ts.URL)
110-
if !strings.HasPrefix(ts.URL, "http") {
111-
ts.URL = "illegal"
108+
t.URL = urlStr[3:] // utf-8下用为3字节
109+
logrus.Println("[群管]" + t.URL)
110+
if !strings.HasPrefix(t.URL, "http") {
111+
t.URL = "illegal"
112112
logrus.Println("[群管]url非法!")
113-
return &ts
113+
return &t
114114
}
115115
}
116-
ts.Alert = dateStrs[6]
117-
ts.SetEn(true)
116+
t.Alert = dateStrs[6]
117+
t.SetEn(true)
118118
}
119-
ts.SelfID = botqq
120-
ts.GrpID = grp
121-
return &ts
119+
t.SelfID = botqq
120+
t.GrpID = grp
121+
return &t
122122
}
123123

124124
// chineseNum2Int 汉字数字转int,仅支持-10~99,最多两位数,其中"每"解释为-1,"每二"为-2,以此类推

plugin_manager/timer/sleep.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (ts *Timer) nextWakeTime() (date time.Time) {
8989
}
9090
logrus.Debugln("[timer] stable:", stable)
9191
logrus.Debugln("[timer] m:", m, "d:", d, "h:", h, "mn:", mn, "w:", w)
92-
date = time.Date(date.Year(), time.Month(m), int(d), int(h), int(mn), date.Second(), date.Nanosecond(), date.Location())
92+
date = time.Date(date.Year(), time.Month(m), d, h, mn, date.Second(), date.Nanosecond(), date.Location())
9393
logrus.Debugln("[timer] date original:", date)
9494
if unit > 0 {
9595
date = date.Add(unit)
@@ -111,7 +111,7 @@ func (ts *Timer) nextWakeTime() (date time.Time) {
111111
}
112112
}
113113
logrus.Debugln("[timer] date after fix:", date)
114-
if stable&0x8 != 0 && date.Hour() != int(h) {
114+
if stable&0x8 != 0 && date.Hour() != h {
115115
switch {
116116
case stable&0x4 == 0:
117117
date = date.AddDate(0, 0, 1).Add(-time.Hour)
@@ -124,7 +124,7 @@ func (ts *Timer) nextWakeTime() (date time.Time) {
124124
}
125125
}
126126
logrus.Debugln("[timer] date after s8:", date)
127-
if stable&0x4 != 0 && date.Day() != int(d) {
127+
if stable&0x4 != 0 && date.Day() != d {
128128
switch {
129129
case stable*0x1 == 0:
130130
date = date.AddDate(0, 1, -1)

plugin_manager/timer/wrap.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,85 +3,85 @@ package timer
33
import "time"
44

55
// En isEnabled 1bit
6-
func (m *Timer) En() (en bool) {
7-
return m.En1Month4Day5Week3Hour5Min6&0x800000 != 0
6+
func (t *Timer) En() (en bool) {
7+
return t.En1Month4Day5Week3Hour5Min6&0x800000 != 0
88
}
99

1010
// Month 4bits
11-
func (m *Timer) Month() (mon time.Month) {
12-
mon = time.Month((m.En1Month4Day5Week3Hour5Min6 & 0x780000) >> 19)
11+
func (t *Timer) Month() (mon time.Month) {
12+
mon = time.Month((t.En1Month4Day5Week3Hour5Min6 & 0x780000) >> 19)
1313
if mon == 0b1111 {
1414
mon = -1
1515
}
1616
return
1717
}
1818

1919
// Day 5bits
20-
func (m *Timer) Day() (d int) {
21-
d = int((m.En1Month4Day5Week3Hour5Min6 & 0x07c000) >> 14)
20+
func (t *Timer) Day() (d int) {
21+
d = int((t.En1Month4Day5Week3Hour5Min6 & 0x07c000) >> 14)
2222
if d == 0b11111 {
2323
d = -1
2424
}
2525
return
2626
}
2727

2828
// Week 3bits
29-
func (m *Timer) Week() (w time.Weekday) {
30-
w = time.Weekday((m.En1Month4Day5Week3Hour5Min6 & 0x003800) >> 11)
29+
func (t *Timer) Week() (w time.Weekday) {
30+
w = time.Weekday((t.En1Month4Day5Week3Hour5Min6 & 0x003800) >> 11)
3131
if w == 0b111 {
3232
w = -1
3333
}
3434
return
3535
}
3636

3737
// Hour 5bits
38-
func (m *Timer) Hour() (h int) {
39-
h = int((m.En1Month4Day5Week3Hour5Min6 & 0x0007c0) >> 6)
38+
func (t *Timer) Hour() (h int) {
39+
h = int((t.En1Month4Day5Week3Hour5Min6 & 0x0007c0) >> 6)
4040
if h == 0b11111 {
4141
h = -1
4242
}
4343
return
4444
}
4545

4646
// Minute 6bits
47-
func (m *Timer) Minute() (min int) {
48-
min = int(m.En1Month4Day5Week3Hour5Min6 & 0x00003f)
47+
func (t *Timer) Minute() (min int) {
48+
min = int(t.En1Month4Day5Week3Hour5Min6 & 0x00003f)
4949
if min == 0b111111 {
5050
min = -1
5151
}
5252
return
5353
}
5454

5555
// SetEn ...
56-
func (m *Timer) SetEn(en bool) {
56+
func (t *Timer) SetEn(en bool) {
5757
if en {
58-
m.En1Month4Day5Week3Hour5Min6 |= 0x800000
58+
t.En1Month4Day5Week3Hour5Min6 |= 0x800000
5959
} else {
60-
m.En1Month4Day5Week3Hour5Min6 &= 0x7fffff
60+
t.En1Month4Day5Week3Hour5Min6 &= 0x7fffff
6161
}
6262
}
6363

6464
// SetMonth ...
65-
func (m *Timer) SetMonth(mon time.Month) {
66-
m.En1Month4Day5Week3Hour5Min6 = ((int32(mon) << 19) & 0x780000) | (m.En1Month4Day5Week3Hour5Min6 & 0x87ffff)
65+
func (t *Timer) SetMonth(mon time.Month) {
66+
t.En1Month4Day5Week3Hour5Min6 = ((int32(mon) << 19) & 0x780000) | (t.En1Month4Day5Week3Hour5Min6 & 0x87ffff)
6767
}
6868

6969
// SetDay ...
70-
func (m *Timer) SetDay(d int) {
71-
m.En1Month4Day5Week3Hour5Min6 = ((int32(d) << 14) & 0x07c000) | (m.En1Month4Day5Week3Hour5Min6 & 0xf83fff)
70+
func (t *Timer) SetDay(d int) {
71+
t.En1Month4Day5Week3Hour5Min6 = ((int32(d) << 14) & 0x07c000) | (t.En1Month4Day5Week3Hour5Min6 & 0xf83fff)
7272
}
7373

7474
// SetWeek ...
75-
func (m *Timer) SetWeek(w time.Weekday) {
76-
m.En1Month4Day5Week3Hour5Min6 = ((int32(w) << 11) & 0x003800) | (m.En1Month4Day5Week3Hour5Min6 & 0xffc7ff)
75+
func (t *Timer) SetWeek(w time.Weekday) {
76+
t.En1Month4Day5Week3Hour5Min6 = ((int32(w) << 11) & 0x003800) | (t.En1Month4Day5Week3Hour5Min6 & 0xffc7ff)
7777
}
7878

7979
// SetHour ...
80-
func (m *Timer) SetHour(h int) {
81-
m.En1Month4Day5Week3Hour5Min6 = ((int32(h) << 6) & 0x0007c0) | (m.En1Month4Day5Week3Hour5Min6 & 0xfff83f)
80+
func (t *Timer) SetHour(h int) {
81+
t.En1Month4Day5Week3Hour5Min6 = ((int32(h) << 6) & 0x0007c0) | (t.En1Month4Day5Week3Hour5Min6 & 0xfff83f)
8282
}
8383

8484
// SetMinute ...
85-
func (m *Timer) SetMinute(min int) {
86-
m.En1Month4Day5Week3Hour5Min6 = (int32(min) & 0x00003f) | (m.En1Month4Day5Week3Hour5Min6 & 0xffffc0)
85+
func (t *Timer) SetMinute(min int) {
86+
t.En1Month4Day5Week3Hour5Min6 = (int32(min) & 0x00003f) | (t.En1Month4Day5Week3Hour5Min6 & 0xffffc0)
8787
}

plugin_novel/qianbi.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111
"strings"
1212
"time"
1313

14-
"github.com/FloatTech/ZeroBot-Plugin/utils/txt2img"
15-
1614
"github.com/antchfx/htmlquery"
1715
log "github.com/sirupsen/logrus"
1816
zero "github.com/wdvxdr1123/ZeroBot"
@@ -22,6 +20,7 @@ import (
2220

2321
"github.com/FloatTech/ZeroBot-Plugin/control"
2422
ub "github.com/FloatTech/ZeroBot-Plugin/utils/binary"
23+
"github.com/FloatTech/ZeroBot-Plugin/utils/txt2img"
2524
)
2625

2726
const (

plugin_omikuji/sensou.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@ import (
77
"strconv"
88
"time"
99

10-
"github.com/wdvxdr1123/ZeroBot/utils/helper"
11-
12-
"github.com/FloatTech/ZeroBot-Plugin/utils/txt2img"
13-
1410
log "github.com/sirupsen/logrus"
15-
16-
"github.com/FloatTech/ZeroBot-Plugin/control"
17-
1811
zero "github.com/wdvxdr1123/ZeroBot"
1912
"github.com/wdvxdr1123/ZeroBot/message"
13+
"github.com/wdvxdr1123/ZeroBot/utils/helper"
14+
15+
"github.com/FloatTech/ZeroBot-Plugin/control"
16+
"github.com/FloatTech/ZeroBot-Plugin/utils/txt2img"
2017
)
2118

2219
const (

plugin_shindan/shindan.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ package shindan
44
import (
55
"time"
66

7-
log "github.com/sirupsen/logrus"
8-
"github.com/wdvxdr1123/ZeroBot/utils/helper"
9-
10-
"github.com/FloatTech/ZeroBot-Plugin/utils/txt2img"
11-
127
"github.com/FloatTech/AnimeAPI/shindanmaker"
8+
log "github.com/sirupsen/logrus"
139
zero "github.com/wdvxdr1123/ZeroBot"
1410
"github.com/wdvxdr1123/ZeroBot/extension/rate"
1511
"github.com/wdvxdr1123/ZeroBot/message"
12+
"github.com/wdvxdr1123/ZeroBot/utils/helper"
1613

1714
"github.com/FloatTech/ZeroBot-Plugin/control"
1815
"github.com/FloatTech/ZeroBot-Plugin/utils/ctxext"
16+
"github.com/FloatTech/ZeroBot-Plugin/utils/txt2img"
1917
)
2018

2119
var (

0 commit comments

Comments
 (0)