mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
第三次提交兽语加密 (#486)
This commit is contained in:
parent
deb655de36
commit
98812b103e
24
README.md
24
README.md
@ -816,6 +816,16 @@ print("run[CQ:image,file="+j["img"]+"]")
|
|||||||
|
|
||||||
- [x] 更新[屌|弔|吊]图
|
- [x] 更新[屌|弔|吊]图
|
||||||
|
|
||||||
|
</details>
|
||||||
|
<details>
|
||||||
|
<summary>兽语加密(嗷呜~)</summary>
|
||||||
|
|
||||||
|
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/jiami"`
|
||||||
|
|
||||||
|
- [x] 兽语加密xxx
|
||||||
|
|
||||||
|
- [x] 兽语解密xxx
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
<details>
|
<details>
|
||||||
<summary>小鸡词典</summary>
|
<summary>小鸡词典</summary>
|
||||||
@ -1214,6 +1224,20 @@ print("run[CQ:image,file="+j["img"]+"]")
|
|||||||
|
|
||||||
- [x] 来份网易云热评
|
- [x] 来份网易云热评
|
||||||
|
|
||||||
|
</details>
|
||||||
|
<details>
|
||||||
|
<summary>天气/拼音查询-名言</summary>
|
||||||
|
|
||||||
|
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenben"`
|
||||||
|
|
||||||
|
- [x] xx天气
|
||||||
|
|
||||||
|
- [x] xx拼音
|
||||||
|
|
||||||
|
- [x] 每日情话/一言/鸡汤
|
||||||
|
|
||||||
|
- [x] 绕口令
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
<details>
|
<details>
|
||||||
<summary>百度文心AI</summary>
|
<summary>百度文心AI</summary>
|
||||||
|
|||||||
2
main.go
2
main.go
@ -95,6 +95,7 @@ import (
|
|||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/image_finder" // 关键字搜图
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/image_finder" // 关键字搜图
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/inject" // 注入指令
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/inject" // 注入指令
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jandan" // 煎蛋网无聊图
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jandan" // 煎蛋网无聊图
|
||||||
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jiami" // 兽语加密
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jikipedia" // 小鸡词典
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jikipedia" // 小鸡词典
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jptingroom" // 日语听力学习材料
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jptingroom" // 日语听力学习材料
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/juejuezi" // 绝绝子生成器
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/juejuezi" // 绝绝子生成器
|
||||||
@ -129,6 +130,7 @@ import (
|
|||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vitsnyaru" // vits猫雷
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vitsnyaru" // vits猫雷
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtb_quotation" // vtb语录
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtb_quotation" // vtb语录
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wangyiyun" // 网易云音乐热评
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wangyiyun" // 网易云音乐热评
|
||||||
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenben" // 文本指令大全
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenxinAI" // 百度文心AI画图
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenxinAI" // 百度文心AI画图
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/word_count" // 聊天热词
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/word_count" // 聊天热词
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词
|
||||||
|
|||||||
65
plugin/jiami/jiami.go
Normal file
65
plugin/jiami/jiami.go
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
// Package jiami 兽语加密与解密
|
||||||
|
package jiami
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/FloatTech/floatbox/web"
|
||||||
|
ctrl "github.com/FloatTech/zbpctrl"
|
||||||
|
"github.com/FloatTech/zbputils/control"
|
||||||
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
jiami1 = "http://ovooa.com/API/sho_u/?msg=%v" // 加密api地址
|
||||||
|
jiami2 = "http://ovooa.com/API/sho_u/?format=1&msg=%v" // 解密api地址
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
type nmd struct { // struct解析格式大概是
|
||||||
|
Data struct {
|
||||||
|
Message string
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { // 主函数
|
||||||
|
en := control.Register("jiami", &ctrl.Options[*zero.Ctx]{
|
||||||
|
DisableOnDefault: false,
|
||||||
|
Brief: "兽语加解密",
|
||||||
|
Help: "兽语加解密\n" +
|
||||||
|
"- 兽语加密xxx\n- 兽语解密xxx",
|
||||||
|
})
|
||||||
|
en.OnRegex(`^兽语加密\s*(.+)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||||
|
str := ctx.State["regex_matched"].([]string)[1]
|
||||||
|
es, err := web.GetData(fmt.Sprintf(jiami1, str)) // 将网站返回结果赋值
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var r nmd // r数组
|
||||||
|
err = json.Unmarshal(es, &r) // 填api返回结果,struct地址
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.SendChain(message.Text(r.Data.Message)) // 输出提取后的结果
|
||||||
|
})
|
||||||
|
|
||||||
|
en.OnRegex(`^兽语解密\s*(.+)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||||
|
str := ctx.State["regex_matched"].([]string)[1]
|
||||||
|
es, err := web.GetData(fmt.Sprintf(jiami2, str)) // 将网站返回结果赋值
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var n nmd // r数组
|
||||||
|
err = json.Unmarshal(es, &n) // 填api返回结果,struct地址
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.SendChain(message.Text(n.Data.Message)) // 输出提取后的结果
|
||||||
|
})
|
||||||
|
}
|
||||||
112
plugin/wenben/wenben.go
Normal file
112
plugin/wenben/wenben.go
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
// Package wenben 文本链接
|
||||||
|
package wenben
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"github.com/FloatTech/floatbox/web"
|
||||||
|
ctrl "github.com/FloatTech/zbpctrl"
|
||||||
|
"github.com/FloatTech/zbputils/control"
|
||||||
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
tianqi = "https://xiaobai.klizi.cn/API/other/weather_1.php?data=&msg=%v" // api地址
|
||||||
|
pinyin = "http://ovooa.com/API/pinyin/api.php?type=text&msg=%v"
|
||||||
|
yiyan = "https://v1.hitokoto.cn/?c=a&c=b&c=c&c=d&c=h&c=i" // 动漫 漫画 游戏 文学 影视 诗词
|
||||||
|
kouling = "http://ovooa.com/API/rao/api.php?type=text" //口令
|
||||||
|
tang = "http://api.btstu.cn/yan/api.php?charset=utf-8&encode=text"
|
||||||
|
qing = "https://xiaobai.klizi.cn/API/other/wtqh.php"
|
||||||
|
)
|
||||||
|
|
||||||
|
type rspData struct {
|
||||||
|
Hitokoto string `json:"hitokoto"`
|
||||||
|
From string `json:"from"`
|
||||||
|
FromWho string `json:"from_who"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { // 主函数
|
||||||
|
en := control.Register("tianqi", &ctrl.Options[*zero.Ctx]{
|
||||||
|
DisableOnDefault: false,
|
||||||
|
Brief: "天气/拼音查询",
|
||||||
|
Help: "文本命令大全\n" +
|
||||||
|
"- 天气查询:xxx天气" +
|
||||||
|
"- 拼音查询:xxx拼音" +
|
||||||
|
"- 每日一言" +
|
||||||
|
"- 每日鸡汤" +
|
||||||
|
"- 每日情话" +
|
||||||
|
"- 绕口令",
|
||||||
|
})
|
||||||
|
en.OnSuffix("天气").SetBlock(true).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
str := ctx.State["args"].(string)
|
||||||
|
es, err := web.GetData(fmt.Sprintf(tianqi, str)) // 将网站返回结果赋值
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.SendChain(message.Text(str, "天气如下:\n", helper.BytesToString(es)))
|
||||||
|
})
|
||||||
|
en.OnSuffix("拼音").SetBlock(true).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
str := ctx.State["args"].(string)
|
||||||
|
es, err := web.GetData(fmt.Sprintf(pinyin, str)) // 将网站返回结果赋值
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.SendChain(message.Text(str, "的拼音为:", helper.BytesToString(es)))
|
||||||
|
})
|
||||||
|
en.OnFullMatch("每日情话").SetBlock(true).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
data, err := web.GetData(qing)
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("获取失败惹", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.SendChain(message.Text(helper.BytesToString(data)))
|
||||||
|
})
|
||||||
|
en.OnFullMatch("每日鸡汤").SetBlock(true).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
data, err := web.GetData(tang)
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("获取失败惹", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.SendChain(message.Text(helper.BytesToString(data)))
|
||||||
|
})
|
||||||
|
en.OnFullMatch("绕口令").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||||
|
data, err := web.GetData(kouling)
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("获取失败惹", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.SendChain(message.Text(helper.BytesToString(data)))
|
||||||
|
})
|
||||||
|
en.OnFullMatch("每日一言").SetBlock(true).Handle(func(ctx *zero.Ctx) { //每日一言
|
||||||
|
var rsp rspData
|
||||||
|
data, err := web.GetData(yiyan)
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("Err:", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = json.Unmarshal(data, &rsp)
|
||||||
|
if err != nil {
|
||||||
|
ctx.SendChain(message.Text("出现错误捏:", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var msg strings.Builder
|
||||||
|
msg.WriteString(rsp.Hitokoto)
|
||||||
|
msg.WriteString("\n出自:")
|
||||||
|
msg.WriteString(rsp.From)
|
||||||
|
msg.WriteByte('\n')
|
||||||
|
if len(rsp.FromWho) != 0 {
|
||||||
|
msg.WriteString("作者:")
|
||||||
|
msg.WriteString(rsp.FromWho)
|
||||||
|
}
|
||||||
|
ctx.SendChain(message.Text(msg.String()))
|
||||||
|
})
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user