Skip to content

Commit

Permalink
✨ 抽老婆插件
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Mar 25, 2023
1 parent 1a0575a commit aa5c324
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 20 deletions.
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ print("run[CQ:image,file="+j["img"]+"]")

- [x] 卖萌[@xxx]

- [x] 抽老婆[@xxx]
- [x] 今日老婆[@xxx]

- [x] 黄油角色[@xxx]

Expand Down Expand Up @@ -1459,19 +1459,11 @@ print("run[CQ:image,file="+j["img"]+"]")

</details>
<details>
<summary>月幕galgame图</summary>

`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal"`

- [x] 随机galCG

- [x] 随机gal表情包
<summary>抽老婆</summary>

- [x] galCG[xxx]

- [x] gal表情包[xxx]
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wife"`

- [x] 更新gal
- [x] 抽老婆

</details>
<details>
Expand Down Expand Up @@ -1518,6 +1510,22 @@ print("run[CQ:image,file="+j["img"]+"]")
- [x] 查卡店 [卡名] -r [稀有度]
- 注:卡店只支持单个稀有度查询

</details>
<details>
<summary>月幕galgame图</summary>

`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal"`

- [x] 随机galCG

- [x] 随机gal表情包

- [x] galCG[xxx]

- [x] gal表情包[xxx]

- [x] 更新gal

</details>
<details>
<summary>词典匹配回复</summary>
Expand Down
2 changes: 1 addition & 1 deletion data
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.20
require (
github.com/Baidu-AIP/golang-sdk v1.1.1
github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3
github.com/FloatTech/floatbox v0.0.0-20230316111222-7ffde57284cc
github.com/FloatTech/floatbox v0.0.0-20230325093157-844e210a5dab
github.com/FloatTech/gg v1.1.2
github.com/FloatTech/imgfactory v0.2.2-0.20230322091809-b0ddbe44b94b
github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9
Expand All @@ -24,6 +24,7 @@ require (
github.com/fumiama/go-base16384 v1.6.4
github.com/fumiama/go-registry v0.2.6
github.com/fumiama/gotracemoe v0.0.3
github.com/fumiama/imgsz v0.0.2
github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565
github.com/fumiama/unibase2n v0.0.0-20221020155353-02876e777430
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
Expand Down Expand Up @@ -51,7 +52,6 @@ require (
github.com/faiface/beep v1.1.0 // indirect
github.com/fumiama/go-simple-protobuf v0.1.0 // indirect
github.com/fumiama/gofastTEA v0.0.10 // indirect
github.com/fumiama/imgsz v0.0.2 // indirect
github.com/gabriel-vasile/mimetype v1.0.4 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3 h1:SyXS1YXrRuzO3YVCZB/5gSX7vaFbSMwzN+RXLNNKq5M=
github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3/go.mod h1:h+22XrJTgcn0m4aM3o1pYo5G0+Mv4v7wW5xvZQ4LabY=
github.com/FloatTech/floatbox v0.0.0-20230316111222-7ffde57284cc h1:1yentlIEJImE0rla5xE7o73ZW37eS/byFhPEwx9WYEs=
github.com/FloatTech/floatbox v0.0.0-20230316111222-7ffde57284cc/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI=
github.com/FloatTech/floatbox v0.0.0-20230325093157-844e210a5dab h1:Tp+uRcdDBukeSowPDEo2iAux8rCd10VWqglC4a238TI=
github.com/FloatTech/floatbox v0.0.0-20230325093157-844e210a5dab/go.mod h1:FwQm6wk+b4wuW54KCKn3zccMX47Q5apnHD/Yakzv0fI=
github.com/FloatTech/gg v1.1.2 h1:YolgOYg3uDHc1+g0bLtt6QuRA/pvLn+b9IBCIhOOX88=
github.com/FloatTech/gg v1.1.2/go.mod h1:uzPzAeT35egARdRuu+1oyjU3CmTwCceoq3Vvje7LpcI=
github.com/FloatTech/imgfactory v0.2.2-0.20230315152233-49741fc994f9 h1:IzZLuM/fgKclyMaU/Qb1qlLdGrs2FTietkqOWhh07Gw=
github.com/FloatTech/imgfactory v0.2.2-0.20230315152233-49741fc994f9/go.mod h1:el5hGpj1C1bDRxcTXYRwEivDCr40zZeJpcrLrB1fajs=
github.com/FloatTech/imgfactory v0.2.2-0.20230322091809-b0ddbe44b94b h1:VMNci4SWBySdw/6poqF9Dn9zlT5ntTFSJOEEBjRnJ/4=
github.com/FloatTech/imgfactory v0.2.2-0.20230322091809-b0ddbe44b94b/go.mod h1:el5hGpj1C1bDRxcTXYRwEivDCr40zZeJpcrLrB1fajs=
github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 h1:hffajvmQFfP68U6wUwHemPuuwCUoss+SEFfoLYwbGwE=
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/warframeapi" // warframeAPI插件
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenben" // 文本指令大全
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenxinAI" // 百度文心AI画图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wife" // 抽老婆
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/word_count" // 聊天热词
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ygo" // 游戏王相关插件
Expand Down
2 changes: 1 addition & 1 deletion plugin/shindan/shindan.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func init() {
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(1075116)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlecq)
engine.OnPrefix("黄油角色", number(1115465)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handlepic)
}

Expand Down
55 changes: 55 additions & 0 deletions plugin/wife/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Package wife 抽老婆
package wife

import (
"encoding/json"

fcext "github.com/FloatTech/floatbox/ctxext"
"github.com/FloatTech/floatbox/file"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)

func init() {
engine := control.Register("wife", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Help: "抽老婆\n" +
"- 抽老婆",
PublicDataFolder: "Wife",
}).ApplySingle(ctxext.DefaultSingle)
cards := []string{}
uriprefix := "file:///" + file.BOTPATH + "/" + engine.DataFolder()
engine.OnFullMatch("抽老婆", fcext.DoOnceOnSuccess(
func(ctx *zero.Ctx) bool {
data, err := engine.GetLazyData("wife.json", true)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false
}
err = json.Unmarshal(data, &cards)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return false
}
logrus.Infof("[wife]加载%d个老婆", len(cards))
return true
},
)).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
card := cards[fcext.RandSenderPerDayN(ctx.Event.UserID, len(cards))]
if id := ctx.SendChain(
message.At(ctx.Event.UserID),
message.Text("今天的二次元老婆是~【", card, "】哒"),
message.Image(uriprefix+"wives/"+card),
); id.ID() == 0 {
ctx.SendChain(
message.At(ctx.Event.UserID),
message.Text("今天的二次元老婆是~【", card, "】哒\n【图片发送失败, 请联系维护者】"),
)
}
})
}

0 comments on commit aa5c324

Please sign in to comment.