From 98812b103e27174aeda1c9e41b8427768ce3795f Mon Sep 17 00:00:00 2001
From: lianhong2758 <2758988938@qq.com>
Date: Sat, 5 Nov 2022 22:15:34 +0800
Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=AC=A1=E6=8F=90=E4=BA=A4?=
=?UTF-8?q?=E5=85=BD=E8=AF=AD=E5=8A=A0=E5=AF=86=20(#486)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 24 +++++++++
main.go | 2 +
plugin/jiami/jiami.go | 65 +++++++++++++++++++++++
plugin/wenben/wenben.go | 112 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 203 insertions(+)
create mode 100644 plugin/jiami/jiami.go
create mode 100644 plugin/wenben/wenben.go
diff --git a/README.md b/README.md
index d950b81d..2907497e 100644
--- a/README.md
+++ b/README.md
@@ -816,6 +816,16 @@ print("run[CQ:image,file="+j["img"]+"]")
- [x] 更新[屌|弔|吊]图
+
+
+ 兽语加密(嗷呜~)
+
+ `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/jiami"`
+
+ - [x] 兽语加密xxx
+
+ - [x] 兽语解密xxx
+
小鸡词典
@@ -1214,6 +1224,20 @@ print("run[CQ:image,file="+j["img"]+"]")
- [x] 来份网易云热评
+
+
+ 天气/拼音查询-名言
+
+ `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenben"`
+
+ - [x] xx天气
+
+ - [x] xx拼音
+
+ - [x] 每日情话/一言/鸡汤
+
+ - [x] 绕口令
+
百度文心AI
diff --git a/main.go b/main.go
index 11bba083..8e4bfa3e 100644
--- a/main.go
+++ b/main.go
@@ -95,6 +95,7 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/image_finder" // 关键字搜图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/inject" // 注入指令
_ "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/jptingroom" // 日语听力学习材料
_ "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/vtb_quotation" // vtb语录
_ "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/word_count" // 聊天热词
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词
diff --git a/plugin/jiami/jiami.go b/plugin/jiami/jiami.go
new file mode 100644
index 00000000..290bc02a
--- /dev/null
+++ b/plugin/jiami/jiami.go
@@ -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)) // 输出提取后的结果
+ })
+}
diff --git a/plugin/wenben/wenben.go b/plugin/wenben/wenben.go
new file mode 100644
index 00000000..fa9233ad
--- /dev/null
+++ b/plugin/wenben/wenben.go
@@ -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()))
+ })
+}