Skip to content

Commit

Permalink
✨ shindan add 黄油角色
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Mar 27, 2022
1 parent 884b0e4 commit 2a78a60
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 19 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ print("run[CQ:image,file="+j["img"]+"]")
- [x] 异世界转生[@xxx]
- [x] 卖萌[@xxx]
- [x] 抽老婆[@xxx]
- [x] 黄油角色[@xxx]
- **AIWife** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/aiwife"`
- [x] waifu | 随机waifu(从[100000个AI生成的waifu](https://www.thiswaifudoesnotexist.net/)中随机一位)
- **gif** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/gif"`
Expand Down
57 changes: 38 additions & 19 deletions plugin/shindan/shindan.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,52 @@ func init() {
"- 卖萌[@xxx]\n" +
"- 抽老婆[@xxx]",
})
engine.OnPrefix("异世界转生", number(587874)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handle)
engine.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handle)
engine.OnPrefix("卖萌", number(360578)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handle)
engine.OnPrefix("抽老婆", number(1075116)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handle)
engine.OnPrefix("异世界转生", number(587874)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic)
engine.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic)
engine.OnPrefix("卖萌", number(360578)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handletxt)
engine.OnPrefix("抽老婆", number(1075116)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlecq)
engine.OnPrefix("黄油角色", number(1115465)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic)
}

// shindanmaker 处理函数
func handle(ctx *zero.Ctx) {
func handletxt(ctx *zero.Ctx) {
// 获取名字
name := ctx.NickName()
// 调用接口
txt, err := shindanmaker.Shindanmaker(ctx.State["id"].(int64), name)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
ctx.SendChain(message.Text("ERROR:", err))
return
}
// TODO: 可注入
switch ctx.State["id"].(int64) {
case 587874, 162207:
data, err := text.RenderToBase64(txt, text.FontFile, 400, 20)
if err != nil {
log.Errorln("[shindan]:", err)
}
if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
default:
ctx.Send(txt)
ctx.SendChain(message.Text(txt))
}

func handlecq(ctx *zero.Ctx) {
// 获取名字
name := ctx.NickName()
// 调用接口
txt, err := shindanmaker.Shindanmaker(ctx.State["id"].(int64), name)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.Send(txt)
}

func handlepic(ctx *zero.Ctx) {
// 获取名字
name := ctx.NickName()
// 调用接口
txt, err := shindanmaker.Shindanmaker(ctx.State["id"].(int64), name)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
data, err := text.RenderToBase64(txt, text.FontFile, 400, 20)
if err != nil {
log.Errorln("[shindan]:", err)
}
if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
}

Expand Down

0 comments on commit 2a78a60

Please sign in to comment.