Skip to content

Commit 2a78a60

Browse files
committed
✨ shindan add 黄油角色
1 parent 884b0e4 commit 2a78a60

File tree

2 files changed

+39
-19
lines changed

2 files changed

+39
-19
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ print("run[CQ:image,file="+j["img"]+"]")
180180
- [x] 异世界转生[@xxx]
181181
- [x] 卖萌[@xxx]
182182
- [x] 抽老婆[@xxx]
183+
- [x] 黄油角色[@xxx]
183184
- **AIWife** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/aiwife"`
184185
- [x] waifu | 随机waifu(从[100000个AI生成的waifu](https://www.thiswaifudoesnotexist.net/)中随机一位)
185186
- **gif** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/gif"`

plugin/shindan/shindan.go

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,52 @@ func init() {
2424
"- 卖萌[@xxx]\n" +
2525
"- 抽老婆[@xxx]",
2626
})
27-
engine.OnPrefix("异世界转生", number(587874)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handle)
28-
engine.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handle)
29-
engine.OnPrefix("卖萌", number(360578)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handle)
30-
engine.OnPrefix("抽老婆", number(1075116)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handle)
27+
engine.OnPrefix("异世界转生", number(587874)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic)
28+
engine.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic)
29+
engine.OnPrefix("卖萌", number(360578)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handletxt)
30+
engine.OnPrefix("抽老婆", number(1075116)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlecq)
31+
engine.OnPrefix("黄油角色", number(1115465)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic)
3132
}
3233

33-
// shindanmaker 处理函数
34-
func handle(ctx *zero.Ctx) {
34+
func handletxt(ctx *zero.Ctx) {
3535
// 获取名字
3636
name := ctx.NickName()
3737
// 调用接口
3838
txt, err := shindanmaker.Shindanmaker(ctx.State["id"].(int64), name)
3939
if err != nil {
40-
ctx.SendChain(message.Text("ERROR: ", err))
40+
ctx.SendChain(message.Text("ERROR:", err))
41+
return
4142
}
42-
// TODO: 可注入
43-
switch ctx.State["id"].(int64) {
44-
case 587874, 162207:
45-
data, err := text.RenderToBase64(txt, text.FontFile, 400, 20)
46-
if err != nil {
47-
log.Errorln("[shindan]:", err)
48-
}
49-
if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 {
50-
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
51-
}
52-
default:
53-
ctx.Send(txt)
43+
ctx.SendChain(message.Text(txt))
44+
}
45+
46+
func handlecq(ctx *zero.Ctx) {
47+
// 获取名字
48+
name := ctx.NickName()
49+
// 调用接口
50+
txt, err := shindanmaker.Shindanmaker(ctx.State["id"].(int64), name)
51+
if err != nil {
52+
ctx.SendChain(message.Text("ERROR:", err))
53+
return
54+
}
55+
ctx.Send(txt)
56+
}
57+
58+
func handlepic(ctx *zero.Ctx) {
59+
// 获取名字
60+
name := ctx.NickName()
61+
// 调用接口
62+
txt, err := shindanmaker.Shindanmaker(ctx.State["id"].(int64), name)
63+
if err != nil {
64+
ctx.SendChain(message.Text("ERROR:", err))
65+
return
66+
}
67+
data, err := text.RenderToBase64(txt, text.FontFile, 400, 20)
68+
if err != nil {
69+
log.Errorln("[shindan]:", err)
70+
}
71+
if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 {
72+
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
5473
}
5574
}
5675

0 commit comments

Comments
 (0)