From e81e596029e0543b281e352b90547525129201c0 Mon Sep 17 00:00:00 2001 From: Suika99 <290760339@qq.com> Date: Thu, 1 Jul 2021 23:49:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/ZeroBot-Plugin.iml | 9 +++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 ++ .idea/workspace.xml | 64 +++++++++++++++++++ go.mod | 1 + go.sum | 2 + .../fansDaily.go | 36 ++++++++++- plugin_diana/zhiwang.go | 29 ++++++--- 8 files changed, 143 insertions(+), 12 deletions(-) create mode 100644 .idea/ZeroBot-Plugin.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml rename {plugin_diana => plugin_bilibili}/fansDaily.go (81%) diff --git a/.idea/ZeroBot-Plugin.iml b/.idea/ZeroBot-Plugin.iml new file mode 100644 index 00000000..5e764c4f --- /dev/null +++ b/.idea/ZeroBot-Plugin.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..447d2aba --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 00000000..fd386a1b --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + \ No newline at end of file diff --git a/go.mod b/go.mod index 8e344f40..1243d0c5 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/FloatTech/ZeroBot-Plugin-Timer v1.2.2 github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect github.com/go-ole/go-ole v1.2.5 // indirect + github.com/robfig/cron v1.2.0 github.com/shirou/gopsutil v3.21.5+incompatible github.com/sirupsen/logrus v1.8.1 github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 diff --git a/go.sum b/go.sum index 6cb7ec20..0b81351c 100644 --- a/go.sum +++ b/go.sum @@ -51,6 +51,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ= +github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k= github.com/shirou/gopsutil v3.21.5+incompatible h1:OloQyEerMi7JUrXiNzy8wQ5XN+baemxSl12QgIzt0jc= github.com/shirou/gopsutil v3.21.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= diff --git a/plugin_diana/fansDaily.go b/plugin_bilibili/fansDaily.go similarity index 81% rename from plugin_diana/fansDaily.go rename to plugin_bilibili/fansDaily.go index 087071f3..7a1f97a7 100644 --- a/plugin_diana/fansDaily.go +++ b/plugin_bilibili/fansDaily.go @@ -1,17 +1,31 @@ -package plugin_diana +package plugin_bilibili import ( + "encoding/json" "github.com/robfig/cron" zero "github.com/wdvxdr1123/ZeroBot" "github.com/wdvxdr1123/ZeroBot/message" + "net/http" + "time" ) +type follower struct { + Mid int `json:"mid"` + Uname string `json:"uname"` + Video int `json:"video"` + Roomid int `json:"roomid"` + Rise int `json:"rise"` + Follower int `json:"follower"` + GuardNum int `json:"guardNum"` + AreaRank int `json:"areaRank"` +} + // 开启日报推送 func init() { zero.OnFullMatch("/开启粉丝日报", zero.AdminPermission). Handle(func(ctx *zero.Ctx) { FansDaily(130591566) //群号传进去给下面发信息的函数 - }) + }) } // 定时任务每天晚上最后2分钟执行一次 @@ -84,7 +98,23 @@ func fansData(groupID int64) { "舰队: ", carol.GuardNum, "\n", "直播总排名: ", carol.AreaRank, "\n", "数据来源: ", "https://vtbs.moe/detail/", "351609538", - )) + )) return true }) } + +// 请求api +func fensiapi(uid string) *follower { + + url := "https://api.vtbs.moe/v1/detail/" + uid + resp, err := http.Get(url) + if err != nil { + panic(err) + } + defer resp.Body.Close() + result := &follower{} + if err := json.NewDecoder(resp.Body).Decode(result); err != nil { + panic(err) + } + return result +} \ No newline at end of file diff --git a/plugin_diana/zhiwang.go b/plugin_diana/zhiwang.go index 364a341e..434ad8ce 100644 --- a/plugin_diana/zhiwang.go +++ b/plugin_diana/zhiwang.go @@ -6,12 +6,23 @@ import ( "github.com/wdvxdr1123/ZeroBot/message" "math" "strconv" + "time" zero "github.com/wdvxdr1123/ZeroBot" "net/http" "strings" ) +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() { @@ -36,21 +47,21 @@ func init() { related := zhiwangjson.Data.Related[0][1].(map[string]interface{}) ctx.SendChain(message.Text( "枝网文本复制检测报告(简洁)", "\n", - "查重时间: ", timecurrent(), "\n", - "总文字复制比: ", math.Floor(zhiwangjson.Data.Rate * 100), "%", "\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["content"].(string)[:102]+".....", "\n", "获赞数", related["like_num"], "\n", zhiwangjson.Data.Related[0][2].(string), "\n", "作者: ", related["m_name"], "\n", - "发表时间: ", timestamp(related["ctime"].(float64)), "\n", + "发表时间: ", time.Unix(int64(related["ctime"].(float64)), 0).Format("2006-01-02 15:04:05"), "\n", "查重结果仅作参考,请注意辨别是否为原创", "\n", "数据来源: https://asoulcnki.asia/", - )) - }else { + )) + } else { return } - }) + }) } // 发起api请求并把返回body交由json库解析 @@ -65,7 +76,7 @@ func zhiwangapi(Text string) *zhiwang { client := &http.Client{} resp, err := client.Do(req) - if err != nil{ + if err != nil { panic(err) } defer resp.Body.Close() @@ -95,4 +106,4 @@ func FullMatchText(src ...string) zero.Rule { } return false } -} +} \ No newline at end of file