Skip to content

增加沙雕app一系列接口 #91

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

Merged
merged 6 commits into from
Dec 24, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,15 @@ zerobot -h -t token -u url [-d|w] [-g 监听地址:端口] qq1 qq2 qq3 ...
- [x] coser
- **小说** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_novel" `
- [x] 小说[xxx]
- **骂人** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_curse"`
- [x] 骂他[@xxx]|骂他[qq号]
- **沙雕app插件** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_shadiao"`
- [x] 骂他[@xxx]|骂他[qq号] (停用)
- [x] 骂我 (停用)
- [x] 哄我
- [x] 渣我
- [x] 来碗绿茶
- [x] 发个朋友圈
- [x] 来碗毒鸡汤
- [x] 讲个段子
- **笑话** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_funny"`
- [x] 讲个笑话[@xxx]|讲个笑话[qq号]
- **TODO...**
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_book_review" // 哀伤雪刃吧推书记录
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_choose" // 选择困难症帮手
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_coser" // 三次元小姐姐
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_curse" // 骂人
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_fortune" // 运势
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_funny" // 笑话
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs" // 炉石
Expand All @@ -43,6 +42,7 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_novel" // 铅笔小说网搜索
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_omikuji" // 浅草寺求签
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_reborn" // 投胎
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shadiao" // 沙雕app
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shindan" // 测定

// b站相关
Expand Down
2 changes: 1 addition & 1 deletion plugin_chat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func init() { // 插件主体
key := ctx.MessageString()
val := *kimomap[key]
text := val[rand.Intn(len(val))]
ctx.SendChain(message.At(ctx.Event.UserID), message.Text(text))
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
})
})
}
8 changes: 4 additions & 4 deletions plugin_coser/coser.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ func init() {
text := gjson.Get(helper.BytesToString(data), "data.Title").String()
m = append(m,
message.CustomNode(
zero.BotConfig.NickName[0],
ctx.Event.SelfID,
ctx.Event.Sender.NickName,
ctx.Event.UserID,
text,
))
gjson.Get(helper.BytesToString(data), "data.data").ForEach(func(_, value gjson.Result) bool {
imgcq := `[CQ:image,file=` + value.String() + `]`
m = append(m,
message.CustomNode(
zero.BotConfig.NickName[0],
ctx.Event.SelfID,
ctx.Event.Sender.NickName,
ctx.Event.UserID,
imgcq),
)
return true
Expand Down
54 changes: 0 additions & 54 deletions plugin_curse/curse.go

This file was deleted.

22 changes: 22 additions & 0 deletions plugin_shadiao/caihongpi.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package shadiao

import (
"github.com/FloatTech/ZeroBot-Plugin/utils/web"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
)

func init() {
engine.OnFullMatch("哄我").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
data, err := web.ReqWith(chpURL, "GET", chpReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(helper.BytesToString(data)))
})
}
22 changes: 22 additions & 0 deletions plugin_shadiao/dujitang.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package shadiao

import (
"github.com/FloatTech/ZeroBot-Plugin/utils/web"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
)

func init() {
engine.OnFullMatch("来碗毒鸡汤").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
data, err := web.ReqWith(duURL, "GET", duReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(helper.BytesToString(data)))
})
}
22 changes: 22 additions & 0 deletions plugin_shadiao/pengyouquan.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package shadiao

import (
"github.com/FloatTech/ZeroBot-Plugin/utils/web"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
)

func init() {
engine.OnFullMatch("发个朋友圈").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
data, err := web.ReqWith(pyqURL, "GET", pyqReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(helper.BytesToString(data)))
})
}
35 changes: 35 additions & 0 deletions plugin_shadiao/shadiao.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Package shadiao 来源于 https://shadiao.app/# 的接口
package shadiao

import (
"github.com/FloatTech/ZeroBot-Plugin/control"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"time"
)

const (
chpURL = "https://chp.shadiao.app/api.php"
duURL = "https://du.shadiao.app/api.php"
pyqURL = "https://pyq.shadiao.app/api.php"
yduanziURL = "http://www.yduanzi.com/duanzi/getduanzi"
chayiURL = "https://api.lovelive.tools/api/SweetNothings/Web/0"
ganhaiURL = "https://api.lovelive.tools/api/SweetNothings/Web/1"
zuanURL = "https://zuanbot.com/api.php?level=min&lang=zh_cn"
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
chpReferer = "https://chp.shadiao.app/"
duReferer = "https://du.shadiao.app/"
pyqReferer = "https://pyq.shadiao.app/"
yduanziReferer = "http://www.yduanzi.com/?utm_source=shadiao.app"
loveliveReferer = "https://lovelive.tools/"
zuanReferer = "https://zuanbot.com/"
prio = 10
)

var (
engine = control.Register("curse", &control.Options{
DisableOnDefault: false,
Help: "沙雕app\n" +
"- 骂他[@xxx]|骂他[qq号](停用)\n- 骂我(停用)\n- 哄我\n- 渣我\n- 来碗绿茶\n- 发个朋友圈\n- 来碗毒鸡汤\n- 讲个段子",
})
limit = rate.NewManager(time.Minute, 60)
)
37 changes: 37 additions & 0 deletions plugin_shadiao/sweetnothings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package shadiao

import (
"github.com/FloatTech/ZeroBot-Plugin/utils/web"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
)

func init() {
engine.OnFullMatch("来碗绿茶").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
data, err := web.ReqWith(chayiURL, "GET", loveliveReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
text := gjson.Get(helper.BytesToString(data), "returnObj.content").String()
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
})

engine.OnFullMatch("渣我").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
data, err := web.ReqWith(ganhaiURL, "GET", loveliveReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
text := gjson.Get(helper.BytesToString(data), "returnObj.content").String()
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
})
}
26 changes: 26 additions & 0 deletions plugin_shadiao/yduanzi.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package shadiao

import (
"github.com/FloatTech/ZeroBot-Plugin/utils/web"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"strings"
)

func init() {
engine.OnFullMatch("讲个段子").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
data, err := web.ReqWith(yduanziURL, "POST", yduanziReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
text := gjson.Get(helper.BytesToString(data), "duanzi").String()
text = strings.Replace(text, "<br>", "\n", -1)
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
})
}
29 changes: 29 additions & 0 deletions plugin_shadiao/zuan.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package shadiao

func init() {
/*
engine.OnFullMatch("骂我").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
data, err := web.ReqWith(zuanURL, "GET", zuanReferer, ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(helper.BytesToString(data)))
})
engine.OnRegex(`^骂他.*?(\d+)`, zero.OnlyGroup).SetBlock(true).SetPriority(40).
Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.GroupID).Acquire() {
return
}
data, err := web.ReqWith(zuanURL, "GET", "", ua)
if err != nil {
ctx.SendChain(message.Text("ERROR:", err))
return
}
ctx.SendChain(message.At(math.Str2Int64(ctx.State["regex_matched"].([]string)[1])), message.Text(helper.BytesToString(data)))
})
*/
}