Skip to content

Commit a3b5a22

Browse files
guohuiyuanGuohuiyuan
andauthored
增加沙雕app一系列接口 (#91)
* feat:添加沙雕app一系列api * fix: 修个文案 * fix:修改等级 * fix:好孩子不能骂人 Co-authored-by: Guohuiyuan <[email protected]>
1 parent f56cee9 commit a3b5a22

File tree

12 files changed

+208
-62
lines changed

12 files changed

+208
-62
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,15 @@ zerobot -h -t token -u url [-d|w] [-g 监听地址:端口] qq1 qq2 qq3 ...
220220
- [x] coser
221221
- **小说** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_novel" `
222222
- [x] 小说[xxx]
223-
- **骂人** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_curse"`
224-
- [x] 骂他[@xxx]|骂他[qq号]
223+
- **沙雕app插件** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_shadiao"`
224+
- [x] 骂他[@xxx]|骂他[qq号] (停用)
225+
- [x] 骂我 (停用)
226+
- [x] 哄我
227+
- [x] 渣我
228+
- [x] 来碗绿茶
229+
- [x] 发个朋友圈
230+
- [x] 来碗毒鸡汤
231+
- [x] 讲个段子
225232
- **笑话** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_funny"`
226233
- [x] 讲个笑话[@xxx]|讲个笑话[qq号]
227234
- **TODO...**

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_book_review" // 哀伤雪刃吧推书记录
3434
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_choose" // 选择困难症帮手
3535
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_coser" // 三次元小姐姐
36-
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_curse" // 骂人
3736
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_fortune" // 运势
3837
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_funny" // 笑话
3938
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs" // 炉石
@@ -43,6 +42,7 @@ import (
4342
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_novel" // 铅笔小说网搜索
4443
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_omikuji" // 浅草寺求签
4544
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_reborn" // 投胎
45+
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shadiao" // 沙雕app
4646
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shindan" // 测定
4747

4848
// b站相关

plugin_chat/chat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func init() { // 插件主体
117117
key := ctx.MessageString()
118118
val := *kimomap[key]
119119
text := val[rand.Intn(len(val))]
120-
ctx.SendChain(message.At(ctx.Event.UserID), message.Text(text))
120+
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
121121
})
122122
})
123123
}

plugin_coser/coser.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ func init() {
4343
text := gjson.Get(helper.BytesToString(data), "data.Title").String()
4444
m = append(m,
4545
message.CustomNode(
46-
zero.BotConfig.NickName[0],
47-
ctx.Event.SelfID,
46+
ctx.Event.Sender.NickName,
47+
ctx.Event.UserID,
4848
text,
4949
))
5050
gjson.Get(helper.BytesToString(data), "data.data").ForEach(func(_, value gjson.Result) bool {
5151
imgcq := `[CQ:image,file=` + value.String() + `]`
5252
m = append(m,
5353
message.CustomNode(
54-
zero.BotConfig.NickName[0],
55-
ctx.Event.SelfID,
54+
ctx.Event.Sender.NickName,
55+
ctx.Event.UserID,
5656
imgcq),
5757
)
5858
return true

plugin_curse/curse.go

Lines changed: 0 additions & 54 deletions
This file was deleted.

plugin_shadiao/caihongpi.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package shadiao
2+
3+
import (
4+
"github.com/FloatTech/ZeroBot-Plugin/utils/web"
5+
zero "github.com/wdvxdr1123/ZeroBot"
6+
"github.com/wdvxdr1123/ZeroBot/message"
7+
"github.com/wdvxdr1123/ZeroBot/utils/helper"
8+
)
9+
10+
func init() {
11+
engine.OnFullMatch("哄我").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
12+
if !limit.Load(ctx.Event.GroupID).Acquire() {
13+
return
14+
}
15+
data, err := web.ReqWith(chpURL, "GET", chpReferer, ua)
16+
if err != nil {
17+
ctx.SendChain(message.Text("ERROR:", err))
18+
return
19+
}
20+
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(helper.BytesToString(data)))
21+
})
22+
}

plugin_shadiao/dujitang.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package shadiao
2+
3+
import (
4+
"github.com/FloatTech/ZeroBot-Plugin/utils/web"
5+
zero "github.com/wdvxdr1123/ZeroBot"
6+
"github.com/wdvxdr1123/ZeroBot/message"
7+
"github.com/wdvxdr1123/ZeroBot/utils/helper"
8+
)
9+
10+
func init() {
11+
engine.OnFullMatch("来碗毒鸡汤").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
12+
if !limit.Load(ctx.Event.GroupID).Acquire() {
13+
return
14+
}
15+
data, err := web.ReqWith(duURL, "GET", duReferer, ua)
16+
if err != nil {
17+
ctx.SendChain(message.Text("ERROR:", err))
18+
return
19+
}
20+
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(helper.BytesToString(data)))
21+
})
22+
}

plugin_shadiao/pengyouquan.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package shadiao
2+
3+
import (
4+
"github.com/FloatTech/ZeroBot-Plugin/utils/web"
5+
zero "github.com/wdvxdr1123/ZeroBot"
6+
"github.com/wdvxdr1123/ZeroBot/message"
7+
"github.com/wdvxdr1123/ZeroBot/utils/helper"
8+
)
9+
10+
func init() {
11+
engine.OnFullMatch("发个朋友圈").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
12+
if !limit.Load(ctx.Event.GroupID).Acquire() {
13+
return
14+
}
15+
data, err := web.ReqWith(pyqURL, "GET", pyqReferer, ua)
16+
if err != nil {
17+
ctx.SendChain(message.Text("ERROR:", err))
18+
return
19+
}
20+
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(helper.BytesToString(data)))
21+
})
22+
}

plugin_shadiao/shadiao.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Package shadiao 来源于 https://shadiao.app/# 的接口
2+
package shadiao
3+
4+
import (
5+
"github.com/FloatTech/ZeroBot-Plugin/control"
6+
"github.com/wdvxdr1123/ZeroBot/extension/rate"
7+
"time"
8+
)
9+
10+
const (
11+
chpURL = "https://chp.shadiao.app/api.php"
12+
duURL = "https://du.shadiao.app/api.php"
13+
pyqURL = "https://pyq.shadiao.app/api.php"
14+
yduanziURL = "http://www.yduanzi.com/duanzi/getduanzi"
15+
chayiURL = "https://api.lovelive.tools/api/SweetNothings/Web/0"
16+
ganhaiURL = "https://api.lovelive.tools/api/SweetNothings/Web/1"
17+
zuanURL = "https://zuanbot.com/api.php?level=min&lang=zh_cn"
18+
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
19+
chpReferer = "https://chp.shadiao.app/"
20+
duReferer = "https://du.shadiao.app/"
21+
pyqReferer = "https://pyq.shadiao.app/"
22+
yduanziReferer = "http://www.yduanzi.com/?utm_source=shadiao.app"
23+
loveliveReferer = "https://lovelive.tools/"
24+
zuanReferer = "https://zuanbot.com/"
25+
prio = 10
26+
)
27+
28+
var (
29+
engine = control.Register("curse", &control.Options{
30+
DisableOnDefault: false,
31+
Help: "沙雕app\n" +
32+
"- 骂他[@xxx]|骂他[qq号](停用)\n- 骂我(停用)\n- 哄我\n- 渣我\n- 来碗绿茶\n- 发个朋友圈\n- 来碗毒鸡汤\n- 讲个段子",
33+
})
34+
limit = rate.NewManager(time.Minute, 60)
35+
)

plugin_shadiao/sweetnothings.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package shadiao
2+
3+
import (
4+
"github.com/FloatTech/ZeroBot-Plugin/utils/web"
5+
"github.com/tidwall/gjson"
6+
zero "github.com/wdvxdr1123/ZeroBot"
7+
"github.com/wdvxdr1123/ZeroBot/message"
8+
"github.com/wdvxdr1123/ZeroBot/utils/helper"
9+
)
10+
11+
func init() {
12+
engine.OnFullMatch("来碗绿茶").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
13+
if !limit.Load(ctx.Event.GroupID).Acquire() {
14+
return
15+
}
16+
data, err := web.ReqWith(chayiURL, "GET", loveliveReferer, ua)
17+
if err != nil {
18+
ctx.SendChain(message.Text("ERROR:", err))
19+
return
20+
}
21+
text := gjson.Get(helper.BytesToString(data), "returnObj.content").String()
22+
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
23+
})
24+
25+
engine.OnFullMatch("渣我").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
26+
if !limit.Load(ctx.Event.GroupID).Acquire() {
27+
return
28+
}
29+
data, err := web.ReqWith(ganhaiURL, "GET", loveliveReferer, ua)
30+
if err != nil {
31+
ctx.SendChain(message.Text("ERROR:", err))
32+
return
33+
}
34+
text := gjson.Get(helper.BytesToString(data), "returnObj.content").String()
35+
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
36+
})
37+
}

0 commit comments

Comments
 (0)