forked from FloatTech/ZeroBot-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
earn.go
68 lines (62 loc) · 1.65 KB
/
earn.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
63
64
65
66
67
68
// 赚钱
package earn
import (
"math/rand"
"github.com/FloatTech/AnimeAPI/wallet"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
var (
engine = control.Register("earn", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "赚钱",
Help: "- \n- 打工\n- 乞讨",
PrivateDataFolder: "earn",
})
)
// 技能CD记录表
type cdsheet struct {
Time int64 // 时间
GroupID int64 // 群号
UserID int64 // 用户
ModeID string // 技能类型
}
func init() {
engine.OnFullMatch("打工", zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
uid := ctx.Event.UserID
add := 10 + rand.Intn(11)
go func() {
err := wallet.InsertWalletOf(uid, add)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
}()
if add != 0 {
ctx.SendChain(message.Text("本次打工获得了:", add, " 个atri币哦~"))
} else {
ctx.SendChain(message.Text("本次打工一无所得哦~"))
}
})
engine.OnFullMatch("乞讨", zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
uid := ctx.Event.UserID
add := rand.Intn(11)
go func() {
err := wallet.InsertWalletOf(uid, add)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
}()
if add != 0 {
ctx.SendChain(message.Text("本次乞讨获得了:", add, " 个atri币哦~"))
} else {
ctx.SendChain(message.Text("本次乞讨一无所得哦~"))
}
})
}