Skip to content

Commit 3b3dd3d

Browse files
committed
✨ fortune 个人用户也可设置底图
1 parent 0817e62 commit 3b3dd3d

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

plugin_fortune/fortune.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,20 @@ func init() {
5353
"- 运势|抽签\n" +
5454
"- 设置底图[车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师]",
5555
})
56-
en.OnRegex(`^设置底图(.*)`, zero.OnlyGroup).SetBlock(true).SecondPriority().
56+
en.OnRegex(`^设置底图(.*)`).SetBlock(true).SecondPriority().
5757
Handle(func(ctx *zero.Ctx) {
58+
gid := ctx.Event.GroupID
59+
if gid <= 0 {
60+
// 个人用户设为负数
61+
gid = -ctx.Event.UserID
62+
}
5863
i, ok := index[ctx.State["regex_matched"].([]string)[1]]
5964
if ok {
60-
conf.Kind[ctx.Event.GroupID] = i
65+
conf.Kind[gid] = i
6166
savecfg("cfg.pb")
67+
ctx.SendChain(message.Text("设置成功~"))
6268
} else {
63-
ctx.Send("没有这个底图哦~")
69+
ctx.SendChain(message.Text("没有这个底图哦~"))
6470
}
6571
})
6672
en.OnFullMatchGroup([]string{"运势", "抽签"}).SetBlock(true).SecondPriority().
@@ -89,7 +95,12 @@ func init() {
8995
}
9096
// 获取该群背景类型,默认车万
9197
kind := "车万"
92-
if v, ok := conf.Kind[ctx.Event.GroupID]; ok {
98+
gid := ctx.Event.GroupID
99+
if gid <= 0 {
100+
// 个人用户设为负数
101+
gid = -ctx.Event.UserID
102+
}
103+
if v, ok := conf.Kind[gid]; ok {
93104
kind = table[v]
94105
}
95106
// 检查背景图片是否存在
@@ -116,13 +127,13 @@ func init() {
116127
t, _ := strconv.ParseInt(time.Now().Format("20060102"), 10, 64)
117128
seed := ctx.Event.UserID + t
118129
// 随机获取背景
119-
background, err := randimage(base+kind+"/", seed)
130+
background, err := randimage(folder+"/", seed)
120131
if err != nil {
121132
ctx.SendChain(message.Text("ERROR: ", err))
122133
return
123134
}
124135
// 随机获取签文
125-
title, text, err := randtext(base+"运势签文.json", seed)
136+
title, text, err := randtext(mikuji, seed)
126137
if err != nil {
127138
ctx.SendChain(message.Text("ERROR: ", err))
128139
return

0 commit comments

Comments
 (0)