From d95760a5340ce52ab5f784c0cd58db8b529f7ec9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?=
<41315874+fumiama@users.noreply.github.com>
Date: Wed, 1 May 2024 02:22:56 +0900
Subject: [PATCH] =?UTF-8?q?chore:=20del=20baidu=20due=20to=20=E4=BD=BF?=
=?UTF-8?q?=E3=81=88=E3=81=AA=E3=81=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 8 ------
main.go | 1 -
plugin/baidu/search.go | 61 ------------------------------------------
3 files changed, 70 deletions(-)
delete mode 100644 plugin/baidu/search.go
diff --git a/README.md b/README.md
index 88978ae4..21c6ad5c 100644
--- a/README.md
+++ b/README.md
@@ -411,14 +411,6 @@ print("run[CQ:image,file="+j["img"]+"]")
- [x] 用yyy解密xxx
-
-
- 百科
-
- `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu"`
-
- - [x] 百度/百科/维基/wiki[xxx]
-
百度内容审核
diff --git a/main.go b/main.go
index a83933be..a0623b8b 100644
--- a/main.go
+++ b/main.go
@@ -65,7 +65,6 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aiwife" // 随机老婆
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/alipayvoice" // 支付宝到账语音
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/autowithdraw" // 触发者撤回时也自动撤回
- _ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu" // 百度一下
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baiduaudit" // 百度内容审核
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/base16384" // base16384加解密
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/base64gua" // base64卦加解密
diff --git a/plugin/baidu/search.go b/plugin/baidu/search.go
deleted file mode 100644
index 91ac83f0..00000000
--- a/plugin/baidu/search.go
+++ /dev/null
@@ -1,61 +0,0 @@
-// Package baidu 百度百科
-package baidu
-
-import (
- "encoding/json"
- "fmt"
- "net/url"
-
- "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 (
- duURL = "https://api.a20safe.com/api.php?api=21&key=%s&text=%s" // api地址
- wikiURL = "https://api.a20safe.com/api.php?api=23&key=%s&text=%s"
- key = "7d06a110e9e20a684e02934549db1d3d"
-)
-
-type result struct {
- Code int `json:"code"`
- Msg string `json:"msg"`
- Data []struct {
- Content string `json:"content"`
- } `json:"data"`
-}
-
-func init() { // 主函数
- en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
- DisableOnDefault: false,
- Help: "百科\n" +
- "- 百度/百科/维基/wiki[关键字]",
- })
- en.OnRegex(`^(百度|维基|百科|wiki)\s*(.+)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
- var es []byte
- var err error
- switch ctx.State["regex_matched"].([]string)[1] {
- case "百度", "百科":
- es, err = web.GetData(fmt.Sprintf(duURL, key, url.QueryEscape(ctx.State["regex_matched"].([]string)[2]))) // 将网站返回结果赋值
- case "wiki", "维基":
- es, err = web.GetData(fmt.Sprintf(wikiURL, key, url.QueryEscape(ctx.State["regex_matched"].([]string)[2]))) // 将网站返回结果赋值
- }
- if err != nil {
- ctx.SendChain(message.Text("出现错误捏:", err))
- return
- }
- var r result // r数组
- err = json.Unmarshal(es, &r) // 填api返回结果,struct地址
- if err != nil {
- ctx.SendChain(message.Text("出现错误捏:", err))
- return
- }
- if r.Code == 0 && len(r.Data) > 0 {
- ctx.SendChain(message.Text(r.Data[0].Content)) // 输出提取后的结果
- } else {
- ctx.SendChain(message.Text("API访问错误"))
- }
- })
-}