forked from FloatTech/ZeroBot-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.go
62 lines (58 loc) · 1.83 KB
/
run.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Package moyu 摸鱼
package moyu
import (
"sync"
"time"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
var (
msg message.Message
mu sync.Mutex
lastupdate time.Time
)
func init() { // 插件主体
control.Register("moyu", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: true,
Brief: "摸鱼提醒",
Help: "- /启用 moyu\n" +
"- /禁用 moyu\n" +
"- 记录在\"0 10 * * *\"触发的指令\n" +
" - 摸鱼提醒",
}).OnFullMatch("摸鱼提醒").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
mu.Lock()
defer mu.Unlock()
if msg == nil || time.Since(lastupdate) > time.Hour*20 {
if registry.Connect() != nil {
return
}
msg = message.Message{
message.Text(time.Now().Format("2006-01-02")),
message.Text("上午好,摸鱼人!\n工作再累,一定不要忘记摸鱼哦!有事没事起身去茶水间,去厕所,去廊道走走别老在工位上坐着,钱是老板的,但命是自己的。\n"),
message.Text(weekend()),
message.Text("\n"),
message.Text(GetHoliday("元旦")),
message.Text("\n"),
message.Text(GetHoliday("春节")),
message.Text("\n"),
message.Text(GetHoliday("清明节")),
message.Text("\n"),
message.Text(GetHoliday("劳动节")),
message.Text("\n"),
message.Text(GetHoliday("端午节")),
message.Text("\n"),
message.Text(GetHoliday("中秋节")),
message.Text("\n"),
message.Text(GetHoliday("国庆节")),
message.Text("\n"),
message.Text("上班是帮老板赚钱,摸鱼是赚老板的钱!最后,祝愿天下所有摸鱼人,都能愉快的渡过每一天…"),
}
_ = registry.Close()
lastupdate = time.Now()
}
ctx.Send(msg)
})
}