Skip to content

Commit 98812b1

Browse files
authored
第三次提交兽语加密 (#486)
1 parent deb655d commit 98812b1

File tree

4 files changed

+203
-0
lines changed

4 files changed

+203
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,16 @@ print("run[CQ:image,file="+j["img"]+"]")
816816

817817
- [x] 更新[屌|弔|吊]
818818

819+
</details>
820+
<details>
821+
<summary>兽语加密(嗷呜~)</summary>
822+
823+
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/jiami"`
824+
825+
- [x] 兽语加密xxx
826+
827+
- [x] 兽语解密xxx
828+
819829
</details>
820830
<details>
821831
<summary>小鸡词典</summary>
@@ -1214,6 +1224,20 @@ print("run[CQ:image,file="+j["img"]+"]")
12141224

12151225
- [x] 来份网易云热评
12161226

1227+
</details>
1228+
<details>
1229+
<summary>天气/拼音查询-名言</summary>
1230+
1231+
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenben"`
1232+
1233+
- [x] xx天气
1234+
1235+
- [x] xx拼音
1236+
1237+
- [x] 每日情话/一言/鸡汤
1238+
1239+
- [x] 绕口令
1240+
12171241
</details>
12181242
<details>
12191243
<summary>百度文心AI</summary>

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ import (
9595
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/image_finder" // 关键字搜图
9696
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/inject" // 注入指令
9797
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jandan" // 煎蛋网无聊图
98+
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jiami" // 兽语加密
9899
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jikipedia" // 小鸡词典
99100
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jptingroom" // 日语听力学习材料
100101
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/juejuezi" // 绝绝子生成器
@@ -129,6 +130,7 @@ import (
129130
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vitsnyaru" // vits猫雷
130131
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtb_quotation" // vtb语录
131132
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wangyiyun" // 网易云音乐热评
133+
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenben" // 文本指令大全
132134
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenxinAI" // 百度文心AI画图
133135
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/word_count" // 聊天热词
134136
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词

plugin/jiami/jiami.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Package jiami 兽语加密与解密
2+
package jiami
3+
4+
import (
5+
"encoding/json"
6+
"fmt"
7+
8+
"github.com/FloatTech/floatbox/web"
9+
ctrl "github.com/FloatTech/zbpctrl"
10+
"github.com/FloatTech/zbputils/control"
11+
zero "github.com/wdvxdr1123/ZeroBot"
12+
"github.com/wdvxdr1123/ZeroBot/message"
13+
)
14+
15+
const (
16+
jiami1 = "http://ovooa.com/API/sho_u/?msg=%v" // 加密api地址
17+
jiami2 = "http://ovooa.com/API/sho_u/?format=1&msg=%v" // 解密api地址
18+
19+
)
20+
21+
type nmd struct { // struct解析格式大概是
22+
Data struct {
23+
Message string
24+
} `json:"data"`
25+
}
26+
27+
func init() { // 主函数
28+
en := control.Register("jiami", &ctrl.Options[*zero.Ctx]{
29+
DisableOnDefault: false,
30+
Brief: "兽语加解密",
31+
Help: "兽语加解密\n" +
32+
"- 兽语加密xxx\n- 兽语解密xxx",
33+
})
34+
en.OnRegex(`^兽语加密\s*(.+)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
35+
str := ctx.State["regex_matched"].([]string)[1]
36+
es, err := web.GetData(fmt.Sprintf(jiami1, str)) // 将网站返回结果赋值
37+
if err != nil {
38+
ctx.SendChain(message.Text("出现错误捏:", err))
39+
return
40+
}
41+
var r nmd // r数组
42+
err = json.Unmarshal(es, &r) // 填api返回结果,struct地址
43+
if err != nil {
44+
ctx.SendChain(message.Text("出现错误捏:", err))
45+
return
46+
}
47+
ctx.SendChain(message.Text(r.Data.Message)) // 输出提取后的结果
48+
})
49+
50+
en.OnRegex(`^兽语解密\s*(.+)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
51+
str := ctx.State["regex_matched"].([]string)[1]
52+
es, err := web.GetData(fmt.Sprintf(jiami2, str)) // 将网站返回结果赋值
53+
if err != nil {
54+
ctx.SendChain(message.Text("出现错误捏:", err))
55+
return
56+
}
57+
var n nmd // r数组
58+
err = json.Unmarshal(es, &n) // 填api返回结果,struct地址
59+
if err != nil {
60+
ctx.SendChain(message.Text("出现错误捏:", err))
61+
return
62+
}
63+
ctx.SendChain(message.Text(n.Data.Message)) // 输出提取后的结果
64+
})
65+
}

plugin/wenben/wenben.go

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// Package wenben 文本链接
2+
package wenben
3+
4+
import (
5+
"encoding/json"
6+
"fmt"
7+
"github.com/FloatTech/floatbox/web"
8+
ctrl "github.com/FloatTech/zbpctrl"
9+
"github.com/FloatTech/zbputils/control"
10+
zero "github.com/wdvxdr1123/ZeroBot"
11+
"github.com/wdvxdr1123/ZeroBot/message"
12+
"github.com/wdvxdr1123/ZeroBot/utils/helper"
13+
"strings"
14+
)
15+
16+
const (
17+
tianqi = "https://xiaobai.klizi.cn/API/other/weather_1.php?data=&msg=%v" // api地址
18+
pinyin = "http://ovooa.com/API/pinyin/api.php?type=text&msg=%v"
19+
yiyan = "https://v1.hitokoto.cn/?c=a&c=b&c=c&c=d&c=h&c=i" // 动漫 漫画 游戏 文学 影视 诗词
20+
kouling = "http://ovooa.com/API/rao/api.php?type=text" //口令
21+
tang = "http://api.btstu.cn/yan/api.php?charset=utf-8&encode=text"
22+
qing = "https://xiaobai.klizi.cn/API/other/wtqh.php"
23+
)
24+
25+
type rspData struct {
26+
Hitokoto string `json:"hitokoto"`
27+
From string `json:"from"`
28+
FromWho string `json:"from_who"`
29+
}
30+
31+
func init() { // 主函数
32+
en := control.Register("tianqi", &ctrl.Options[*zero.Ctx]{
33+
DisableOnDefault: false,
34+
Brief: "天气/拼音查询",
35+
Help: "文本命令大全\n" +
36+
"- 天气查询:xxx天气" +
37+
"- 拼音查询:xxx拼音" +
38+
"- 每日一言" +
39+
"- 每日鸡汤" +
40+
"- 每日情话" +
41+
"- 绕口令",
42+
})
43+
en.OnSuffix("天气").SetBlock(true).
44+
Handle(func(ctx *zero.Ctx) {
45+
str := ctx.State["args"].(string)
46+
es, err := web.GetData(fmt.Sprintf(tianqi, str)) // 将网站返回结果赋值
47+
if err != nil {
48+
ctx.SendChain(message.Text("出现错误捏:", err))
49+
return
50+
}
51+
ctx.SendChain(message.Text(str, "天气如下:\n", helper.BytesToString(es)))
52+
})
53+
en.OnSuffix("拼音").SetBlock(true).
54+
Handle(func(ctx *zero.Ctx) {
55+
str := ctx.State["args"].(string)
56+
es, err := web.GetData(fmt.Sprintf(pinyin, str)) // 将网站返回结果赋值
57+
if err != nil {
58+
ctx.SendChain(message.Text("出现错误捏:", err))
59+
return
60+
}
61+
ctx.SendChain(message.Text(str, "的拼音为:", helper.BytesToString(es)))
62+
})
63+
en.OnFullMatch("每日情话").SetBlock(true).
64+
Handle(func(ctx *zero.Ctx) {
65+
data, err := web.GetData(qing)
66+
if err != nil {
67+
ctx.SendChain(message.Text("获取失败惹", err))
68+
return
69+
}
70+
ctx.SendChain(message.Text(helper.BytesToString(data)))
71+
})
72+
en.OnFullMatch("每日鸡汤").SetBlock(true).
73+
Handle(func(ctx *zero.Ctx) {
74+
data, err := web.GetData(tang)
75+
if err != nil {
76+
ctx.SendChain(message.Text("获取失败惹", err))
77+
return
78+
}
79+
ctx.SendChain(message.Text(helper.BytesToString(data)))
80+
})
81+
en.OnFullMatch("绕口令").SetBlock(true).Handle(func(ctx *zero.Ctx) {
82+
data, err := web.GetData(kouling)
83+
if err != nil {
84+
ctx.SendChain(message.Text("获取失败惹", err))
85+
return
86+
}
87+
ctx.SendChain(message.Text(helper.BytesToString(data)))
88+
})
89+
en.OnFullMatch("每日一言").SetBlock(true).Handle(func(ctx *zero.Ctx) { //每日一言
90+
var rsp rspData
91+
data, err := web.GetData(yiyan)
92+
if err != nil {
93+
ctx.SendChain(message.Text("Err:", err))
94+
return
95+
}
96+
err = json.Unmarshal(data, &rsp)
97+
if err != nil {
98+
ctx.SendChain(message.Text("出现错误捏:", err))
99+
return
100+
}
101+
var msg strings.Builder
102+
msg.WriteString(rsp.Hitokoto)
103+
msg.WriteString("\n出自:")
104+
msg.WriteString(rsp.From)
105+
msg.WriteByte('\n')
106+
if len(rsp.FromWho) != 0 {
107+
msg.WriteString("作者:")
108+
msg.WriteString(rsp.FromWho)
109+
}
110+
ctx.SendChain(message.Text(msg.String()))
111+
})
112+
}

0 commit comments

Comments
 (0)