fix:修复了枝网查重无法使用的问题 (#175)

* 优化在两个命令中使用空格分隔的体验
- fortune的设置底图功能
- b14的加密功能

* 优化四个插件中使用空格分隔的体验
- 加密
- 哔哩哔哩推送
- 藏头诗
- 运势

* 优化并修正了上一个commit
- 加上了因为复制粘贴疏忽又没有注意测试遗漏的`?`
- 调整藏头诗和加密的正则触发,使其不必多此一举
- 删去了未被发现的测试代码

* - 删去了遗漏的Trim

* 优化了更多插件中使用空格的体验
- 优化了music bilibili image_finder 中使用空格的体验
- 补上了plugin_bilibili中未实现的vup开头触发
- 为plugin_bilibili_parse输出的消息加上一个换行符,优化排版

* 小调整

- 考虑到屌字既难打又有碍观瞻,改为正则匹配`[屌|弔|吊]图`
- 增加了退群提醒的定制

* - 修复退群提醒本身忘记修改了的问题

* fix:修复了枝网查重无法使用的问题

* readme适配上次的欢迎语修改

* 删去调试语句

* Update setu_geter.go

* Update zhiwang.go

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
This commit is contained in:
莫思潋 2022-03-31 19:36:29 +08:00 committed by GitHub
parent 8e4c496b54
commit 0698d8e3b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 36 deletions

View File

@ -148,7 +148,7 @@ print("run[CQ:image,file="+j["img"]+"]")
- [x] 退出群聊[群号]@Bot
- [x] *入群欢迎
- [x] *退群通知
- [x] 设置欢迎语[欢迎~] 可选添加 [{at}] [{nickname}] [{avatar}]
- [x] 设置欢迎语[欢迎~] 可选添加 [{at}] [{nickname}] [{avatar}] [{id}]
- [x] 在[MM]月[dd]日的[hh]点[mm]分时(用[url])提醒大家[xxx]
- [x] 在[MM]月[每周 | 周几]的[hh]点[mm]分时(用[url])提醒大家[xxx]
- [x] 取消在[MM]月[dd]日的[hh]点[mm]分的提醒

View File

@ -3,10 +3,11 @@ package diana
import (
"bytes"
"encoding/json"
"io"
"math"
"time"
"github.com/tidwall/gjson"
"github.com/wdvxdr1123/ZeroBot/message"
"net/http"
@ -15,17 +16,6 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
)
type zhiwang struct {
Code int `json:"code"`
Data struct {
EndTime int `json:"end_time"`
Rate float64 `json:"rate"`
Related [][]interface{} `json:"related"`
StartTime int `json:"start_time"`
} `json:"data"`
Message string `json:"message"`
}
// 小作文查重: 回复要查的消息 查重
func init() {
engine.OnMessage(fullmatch("查重")).SetBlock(true).
@ -34,28 +24,27 @@ func init() {
if msg[0].Type == "reply" {
msg := ctx.GetMessage(message.NewMessageID(msg[0].Data["id"])).Elements[0].Data["text"]
zhiwangjson := zhiwangapi(msg)
if zhiwangjson == nil || zhiwangjson.Code != 0 {
if zhiwangjson == nil || zhiwangjson.Get("code").Int() != 0 {
ctx.SendChain(message.Text("api返回错误"))
return
}
if len(zhiwangjson.Data.Related) == 0 {
ctx.SendChain(message.Text("枝网没搜到查重率为0%我的评价是:一眼真"))
if zhiwangjson.Get("data.related.#").Int() == 0 {
ctx.SendChain(message.Text("枝网没搜到查重率为0%鉴定为原创"))
return
}
related := zhiwangjson.Data.Related[0][1].(map[string]interface{})
related := zhiwangjson.Get("data.related.0.reply").Map()
rate := zhiwangjson.Get("data.related.0.rate").Float()
ctx.SendChain(message.Text(
"枝网文本复制检测报告(简洁)", "\n",
"查重时间: ", time.Now().Format("2006-01-02 15:04:05"), "\n",
"总文字复制比: ", math.Floor(zhiwangjson.Data.Rate*100), "%", "\n",
"相似小作文:", "\n",
related["content"].(string)[:102]+".....", "\n",
"获赞数", related["like_num"], "\n",
zhiwangjson.Data.Related[0][2].(string), "\n",
"作者: ", related["m_name"], "\n",
"发表时间: ", time.Unix(int64(related["ctime"].(float64)), 0).Format("2006-01-02 15:04:05"), "\n",
"总文字复制比: ", math.Floor(rate*100), "%", "\n",
"相似小作文", "\n",
related["content"].String()[:102]+".....", "\n",
"获赞数", related["like_num"].String(), "\n",
zhiwangjson.Get("data.related.0.reply_url").String(), "\n",
"作者: ", related["m_name"].String(), "\n",
"发表时间: ", time.Unix(int64(related["ctime"].Float()), 0).Format("2006-01-02 15:04:05"), "\n",
"查重结果仅作参考,请注意辨别是否为原创", "\n",
"数据来源: https://asoulcnki.asia/",
))
@ -63,8 +52,7 @@ func init() {
})
}
// 发起api请求并把返回body交由json库解析
func zhiwangapi(text string) *zhiwang {
func zhiwangapi(text string) *gjson.Result {
url := "https://asoulcnki.asia/v1/api/check"
post := "{\n\"text\":\"" + text + "\"\n}"
var jsonStr = []byte(post)
@ -78,13 +66,13 @@ func zhiwangapi(text string) *zhiwang {
if err != nil {
return nil
}
defer resp.Body.Close()
result := &zhiwang{}
if err1 := json.NewDecoder(resp.Body).Decode(result); err1 != nil {
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil
}
return result
resp.Body.Close()
result := gjson.ParseBytes(bodyBytes)
return &result
}
func fullmatch(src ...string) zero.Rule {

View File

@ -76,7 +76,7 @@ func init() { // 插件主体
}
}()
engine.OnRegex(`^来份(.*)$`, ctxext.FirstValueInList(pool)).SetBlock(true).Limit(ctxext.LimitByUser).
engine.OnRegex(`^来份(.+)$`, ctxext.FirstValueInList(pool)).SetBlock(true).Limit(ctxext.LimitByUser).
Handle(func(ctx *zero.Ctx) {
var imgtype = ctx.State["regex_matched"].([]string)[1]
// 补充池子
@ -96,7 +96,7 @@ func init() { // 插件主体
}
})
engine.OnRegex(`^添加(.*?)(\d+)$`, zero.SuperUserPermission).SetBlock(true).
engine.OnRegex(`^添加(.+)\s?(\d+)$`, zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
var (
imgtype = ctx.State["regex_matched"].([]string)[1]
@ -110,7 +110,7 @@ func init() { // 插件主体
ctx.SendChain(message.Text("成功向分类", imgtype, "添加图片", id))
})
engine.OnRegex(`^删除(.*?)(\d+)$`, ctxext.FirstValueInList(pool), zero.SuperUserPermission).SetBlock(true).
engine.OnRegex(`^删除(.+)\s?(\d+)$`, ctxext.FirstValueInList(pool), zero.SuperUserPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
var (
imgtype = ctx.State["regex_matched"].([]string)[1]