Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ 添加两个api接口 #886

Merged
merged 6 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 64 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ zerobot [-h] [-m] [-n nickname] [-t token] [-u url] [-g url] [-p prefix] [-d|w]
- [x] 列出所有提醒

- [x] 翻牌

- [x] 赞我

- [x] [开启 | 关闭]入群验证

Expand Down Expand Up @@ -959,6 +961,24 @@ print("run[CQ:image,file="+j["img"]+"]")
来份萝莉
```

</details>
<details>
<summary>桑帛云 API</summary>

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

- [x] 随机妹子

- [x] 随机绕口令

- [x] 颜值鉴定[图片]

- [x] 随机情话

- [x] 发病 嘉然

- [x] 让[塔菲|嘉然|东雪莲]说我测尼玛

</details>
<details>
<summary>MagicPrompt-Stable-Diffusion吟唱提示</summary>
Expand Down Expand Up @@ -1517,6 +1537,18 @@ print("run[CQ:image,file="+j["img"]+"]")

- [x] 团队七阶猜单词

</details>
<details>
<summary>鬼东西</summary>

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

- [x] 鬼东西列表

- [x] 查询鬼东西[序号][@xxx]

- 注:由于需要科学,默认注释。

</details>
<details>
<summary>一些游戏王插件</summary>
Expand Down Expand Up @@ -1558,15 +1590,39 @@ print("run[CQ:image,file="+j["img"]+"]")

</details>
<details>
<summary>鬼东西</summary>
<summary>遇见API</summary>

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

- [x] 鬼东西列表

- [x] 查询鬼东西[序号][@xxx]

- 注:由于需要科学,默认注释。
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/yujn"`

- [x] 小姐姐视频
- [x] 小姐姐视频2
- [x] 黑丝视频
- [x] 白丝视频
- [x] 欲梦视频
- [x] 甜妹视频
- [x] 双倍快乐
- [x] 纯情女高
- [x] 萝莉视频
- [x] 玉足视频
- [x] 帅哥视频
- [x] 热舞视频
- [x] 吊带视频
- [x] 汉服视频
- [x] 极品狱卒
- [x] 清纯视频
- [x] 快手变装
- [x] 抖音变装
- [x] 萌娃视频
- [x] 穿搭视频
- [x] 完美身材
- [x] 御姐撒娇
- [x] 绿茶语音
- [x] 怼人语音
- [x] 随机骚话
- [x] 随机污句子
- [x] 随机美句
- [x] 土味情话
- [x] 让[丁真|陈泽|梅西|孙笑川|科比|懒羊羊|胡桃|雫るる]说我测尼玛

</details>

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/tidwall/gjson v1.14.4
github.com/wcharczuk/go-chart/v2 v2.1.0
github.com/wdvxdr1123/ZeroBot v1.7.5-0.20231009162356-57f71b9f5258
github.com/wdvxdr1123/ZeroBot v1.7.5-0.20240410141841-6970df23ca54
gitlab.com/gomidi/midi/v2 v2.0.25
golang.org/x/image v0.3.0
golang.org/x/sys v0.8.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYm
github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4=
github.com/wcharczuk/go-chart/v2 v2.1.0 h1:tY2slqVQ6bN+yHSnDYwZebLQFkphK4WNrVwnt7CJZ2I=
github.com/wcharczuk/go-chart/v2 v2.1.0/go.mod h1:yx7MvAVNcP/kN9lKXM/NTce4au4DFN99j6i1OwDclNA=
github.com/wdvxdr1123/ZeroBot v1.7.5-0.20231009162356-57f71b9f5258 h1:Q0dKoj9SHrR8WjjlcX+eyYBjQKqBn/x1pdJJO1IIOxQ=
github.com/wdvxdr1123/ZeroBot v1.7.5-0.20231009162356-57f71b9f5258/go.mod h1:y29UIOy0RD3P+0meDNIWRhcJF3jtWPN9xP9hgt/AJAU=
github.com/wdvxdr1123/ZeroBot v1.7.5-0.20240410141841-6970df23ca54 h1:s7k0Pf4RoeCUHe9rlVsg0mqAH3WO7xLMhe9qih/CxnE=
github.com/wdvxdr1123/ZeroBot v1.7.5-0.20240410141841-6970df23ca54/go.mod h1:y29UIOy0RD3P+0meDNIWRhcJF3jtWPN9xP9hgt/AJAU=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/juejuezi" // 绝绝子生成器
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/kfccrazythursday" // 疯狂星期四
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/lolicon" // lolicon 随机图片
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/lolimi" // 桑帛云 API
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/magicprompt" // magicprompt吟唱提示
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/mcfish" // 钓鱼模拟器
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/midicreate" // 简易midi音乐制作
Expand Down Expand Up @@ -153,6 +154,7 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ygo" // 游戏王相关插件
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal" // 月幕galgame
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/yujn" // 遇见API

// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wtf" // 鬼东西

Expand Down
133 changes: 133 additions & 0 deletions plugin/lolimi/lolimi.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
// Package lolimi 来源于 https://api.lolimi.cn/ 的接口
package lolimi

import (
"fmt"
"net/url"
"strconv"
"strings"

"github.com/FloatTech/floatbox/binary"
"github.com/FloatTech/floatbox/web"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)

const (
lolimiURL = "https://api.lolimi.cn"
jiaranURL = lolimiURL + "/API/yyhc/jr.php?msg=%v&type=2"
tafeiURL = lolimiURL + "/API/yyhc/taf.php?msg=%v&type=2"
dxlURL = lolimiURL + "/API/yyhc/dxl.php?msg=%v&type=2"
raoURL = lolimiURL + "/API/rao/api.php"
yanURL = lolimiURL + "/API/yan/?url=%v"
xjjURL = lolimiURL + "/API/tup/xjj.php"
qingURL = lolimiURL + "/API/qing/api.php"
fabingURL = lolimiURL + "/API/fabing/fb.php?name=%v"
)

var (
engine = control.AutoRegister(&ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "桑帛云 API",
Help: "- 让[塔菲|嘉然|东雪莲]说我测尼玛\n- 随机绕口令\n- 颜值鉴定[图片]\n" +
"- 随机妹子\n- 随机情话\n- 发病 嘉然\n\n说明: 颜值鉴定只能鉴定三次元图片",
})
)

func init() {
engine.OnFullMatch("随机妹子").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Image(xjjURL))
})
engine.OnFullMatch("随机绕口令").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.GetData(raoURL)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(gjson.Get(binary.BytesToString(data), "data.Msg").String()))
})
engine.OnFullMatch("随机情话").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
data, err := web.GetData(qingURL)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(binary.BytesToString(data)))
})
engine.OnPrefix(`发病`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
name := ctx.NickName()
data, err := web.GetData(fmt.Sprintf(fabingURL, url.QueryEscape(name)))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(gjson.Get(binary.BytesToString(data), "data").String()))
})
engine.OnKeywordGroup([]string{"颜值鉴定"}, zero.MustProvidePicture).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
list := ctx.State["image_url"].([]string)
if len(list) > 0 {
ctx.SendChain(message.Text("少女祈祷中..."))
data, err := web.GetData(fmt.Sprintf(yanURL, url.QueryEscape(list[0])))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
assessment := gjson.Get(binary.BytesToString(data), "data.text").String()
if assessment == "" {
ctx.SendChain(message.Text("ERROR: 请输入正确的图片"))
return
}
var text strings.Builder // 创建一个strings.Builder实例
text.WriteString("评价: ")
text.WriteString(assessment) // 添加评估信息

for i := 0; i <= 2; i++ {
key := gjson.Get(binary.BytesToString(data), "data.grade.key"+strconv.Itoa(i)).String()
score := gjson.Get(binary.BytesToString(data), "data.grade.score"+strconv.Itoa(i)).String()
if key != "" {
text.WriteString("\n")
text.WriteString(key)
text.WriteString(": ")
text.WriteString(score)
}
}

ctx.SendChain(message.Text(text.String())) // 发送构建好的字符串
}
})
engine.OnRegex("^让(塔菲|嘉然|东雪莲)说([\\s\u4e00-\u9fa5\u3040-\u309F\u30A0-\u30FF\\w\\p{P}\u3000-\u303F\uFF00-\uFFEF]+)$").Limit(ctxext.LimitByGroup).Handle(func(ctx *zero.Ctx) {
name := ctx.State["regex_matched"].([]string)[1]
msg := ctx.State["regex_matched"].([]string)[2]
recordURL := ""
switch name {
fumiama marked this conversation as resolved.
Show resolved Hide resolved
case "塔菲":
data, err := web.GetData(fmt.Sprintf(tafeiURL, url.QueryEscape(msg)))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
recordURL = gjson.Get(binary.BytesToString(data), "music").String()
case "嘉然":
recordURL = fmt.Sprintf(jiaranURL, url.QueryEscape(msg))
case "东雪莲":
data, err := web.GetData(fmt.Sprintf(dxlURL, url.QueryEscape(msg)))
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
recordURL = gjson.Get(binary.BytesToString(data), "music").String()
default:
recordURL = fmt.Sprintf(jiaranURL, url.QueryEscape(msg))
}
if recordURL == "" {
ctx.SendChain(message.Text("ERROR: 语音生成失败"))
return
}
ctx.SendChain(message.Record(recordURL))
})
}
19 changes: 19 additions & 0 deletions plugin/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const (
"- 取消在\"cron\"的提醒\n" +
"- 列出所有提醒\n" +
"- 翻牌\n" +
"- 赞我\n" +
"- 设置欢迎语XXX 可选添加 [{at}] [{nickname}] [{avatar}] [{uid}] [{gid}] [{groupname}]\n" +
"- 测试欢迎语\n" +
"- 设置告别辞 参数同设置欢迎语\n" +
Expand Down Expand Up @@ -384,6 +385,24 @@ func init() { // 插件主体
),
)
})
// 给好友点赞
engine.OnFullMatch("赞我").SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
list := ctx.GetFriendList().Array()
flag := false
for _, v := range list {
if ctx.Event.UserID == v.Get("user_id").Int() {
flag = true
fumiama marked this conversation as resolved.
Show resolved Hide resolved
break
}
}
if !flag {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("不加好友不给赞!"))
return
}
ctx.SendLike(ctx.Event.UserID, 10)
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("给你赞了10下哦,记得回我~"))
})
// 入群欢迎
engine.OnNotice().SetBlock(false).
Handle(func(ctx *zero.Ctx) {
Expand Down
Loading
Loading