Skip to content

Commit

Permalink
💩👌 make lint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Aug 6, 2021
1 parent 40f1b1c commit fd64016
Show file tree
Hide file tree
Showing 25 changed files with 548 additions and 126 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ data/SetuTime/cache
data/SetuTime/search
data/manager
.idea/
.DS_Store
.DS_Store
.vscode
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/FloatTech/ZeroBot-ACGImage v1.5.5
github.com/FloatTech/ZeroBot-Plugin-Timer v1.3.4
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/golang/protobuf v1.5.2
github.com/robfig/cron v1.2.0
github.com/shirou/gopsutil v3.21.7+incompatible
github.com/sirupsen/logrus v1.8.1
Expand All @@ -17,5 +18,6 @@ require (
github.com/wdvxdr1123/ZeroBot v1.2.2
golang.org/x/text v0.3.6 // indirect
golang.org/x/tools v0.1.5 // indirect
google.golang.org/protobuf v1.27.1 // indirect
modernc.org/sqlite v1.12.0
)
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25Kn
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY=
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand All @@ -38,6 +40,8 @@ github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMW
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
Expand Down Expand Up @@ -85,23 +89,27 @@ github.com/tklauser/numcpus v0.2.3 h1:nQ0QYpiritP6ViFhrKYsiv6VVxOpum2Gks5GhnJbS/
github.com/tklauser/numcpus v0.2.3/go.mod h1:vpEPS/JC+oZGGQ/My/vJnNsvMDQL6PwOqt8dsCw5j+E=
github.com/wdvxdr1123/ZeroBot v1.2.2 h1:BKEy3l80BMrQWpFWaII0AfFMyf9bqrB0TxfWhTdoV58=
github.com/wdvxdr1123/ZeroBot v1.2.2/go.mod h1:83nHtG8V5TAxPwH/LCDxLpZk4khIgs29dkr5TBWf7fc=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand All @@ -127,7 +135,9 @@ golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand All @@ -138,6 +148,8 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
Expand Down
6 changes: 2 additions & 4 deletions plugin_ai_false/ai_false.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/*
暂时只有服务器监控
*/
package plugin_ai_false
// Package aifalse 暂时只有服务器监控
package aifalse

import (
"math"
Expand Down
66 changes: 34 additions & 32 deletions plugin_atri/atri.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Package atri
// 本文件基于 https://github.com/Kyomotoi/ATRI
// 为 Golang 移植版,语料、素材均来自上述项目
// 本项目遵守 AGPL v3 协议进行开源
/*
Package atri
本文件基于 https://github.com/Kyomotoi/ATRI
为 Golang 移植版,语料、素材均来自上述项目
本项目遵守 AGPL v3 协议进行开源
*/
package atri

import (
Expand All @@ -14,25 +16,25 @@ import (

var (
// ATRI 所有命令的优先级
PRIO = -1
prio = -1
// ATRI 表情的 GitHub 镜像位置
RES = "https://raw.dihe.moe/Yiwen-Chan/ZeroBot-Plugin/master/plugin_atri/"
res = "https://raw.dihe.moe/Yiwen-Chan/ZeroBot-Plugin/master/plugin_atri/"
// ATRI 的总开关
ENABLE = true
enable = true
)

func init() { // 插件主体
zero.OnFullMatch("ATRI醒醒", zero.AdminPermission).SetBlock(true).SetPriority(PRIO).
zero.OnFullMatch("ATRI醒醒", zero.AdminPermission).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
ENABLE = true
enable = true
ctx.SendChain(randText("嗯呜呜……夏生先生……?"))
})
zero.OnFullMatch("ATRI睡吧", zero.AdminPermission).SetBlock(true).SetPriority(PRIO).
zero.OnFullMatch("ATRI睡吧", zero.AdminPermission).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
ENABLE = false
enable = false
ctx.SendChain(randText("Zzz……Zzz……"))
})
zero.OnFullMatch("萝卜子", AtriSwitch(), AtriSleep()).SetBlock(true).SetPriority(PRIO).
zero.OnFullMatch("萝卜子", atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
switch rand.Intn(2) {
case 0:
Expand All @@ -41,17 +43,17 @@ func init() { // 插件主体
ctx.SendChain(randRecord("RocketPunch.amr"))
}
})
zero.OnKeywordGroup([]string{"喜欢", "爱你", "爱", "suki", "daisuki", "すき", "好き", "贴贴", "老婆", "亲一个", "mua"}, AtriSwitch(), AtriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(PRIO).
zero.OnKeywordGroup([]string{"喜欢", "爱你", "爱", "suki", "daisuki", "すき", "好き", "贴贴", "老婆", "亲一个", "mua"}, atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
if rand.Intn(10) == 0 {
ctx.SendChain(randImage("SUKI.jpg", "SUKI1.jpg", "SUKI2.png"))
}
})
zero.OnKeywordGroup([]string{"草你妈", "操你妈", "脑瘫", "废柴", "fw", "five", "废物", "战斗", "爬", "爪巴", "sb", "SB", "傻B"}, AtriSwitch(), AtriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(PRIO - 1).
zero.OnKeywordGroup([]string{"草你妈", "操你妈", "脑瘫", "废柴", "fw", "five", "废物", "战斗", "爬", "爪巴", "sb", "SB", "傻B"}, atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio - 1).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(randImage("FN.jpg", "WQ.jpg", "WQ1.jpg"))
})
zero.OnFullMatchGroup([]string{"早安", "早哇", "早上好", "ohayo", "哦哈哟", "お早う"}, AtriSwitch()).SetBlock(true).SetPriority(PRIO).
zero.OnFullMatchGroup([]string{"早安", "早哇", "早上好", "ohayo", "哦哈哟", "お早う"}, atriSwitch()).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
now := time.Now().Hour()
switch {
Expand Down Expand Up @@ -90,7 +92,7 @@ func init() { // 插件主体
))
}
})
zero.OnFullMatchGroup([]string{"中午好", "午安"}, AtriSwitch()).SetBlock(true).SetPriority(PRIO).
zero.OnFullMatchGroup([]string{"中午好", "午安"}, atriSwitch()).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
now := time.Now().Hour()
if now > 11 && now < 15 { // 中午
Expand All @@ -102,7 +104,7 @@ func init() { // 插件主体
))
}
})
zero.OnFullMatchGroup([]string{"晚安", "oyasuminasai", "おやすみなさい"}, AtriSwitch()).SetBlock(true).SetPriority(PRIO).
zero.OnFullMatchGroup([]string{"晚安", "oyasuminasai", "おやすみなさい"}, atriSwitch()).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
now := time.Now().Hour()
switch {
Expand Down Expand Up @@ -144,7 +146,7 @@ func init() { // 插件主体
))
}
})
zero.OnKeywordGroup([]string{"高性能", "太棒了", "すごい", "sugoi", "斯国一", "よかった"}, AtriSwitch(), AtriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(PRIO).
zero.OnKeywordGroup([]string{"高性能", "太棒了", "すごい", "sugoi", "斯国一", "よかった"}, atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(randText(
"当然,我是高性能的嘛~!",
Expand All @@ -164,7 +166,7 @@ func init() { // 插件主体
"呣......我的高性能,毫无遗憾地施展出来了......",
))
})
zero.OnKeywordGroup([]string{"没事", "没关系", "大丈夫", "还好", "不要紧", "没出大问题", "没伤到哪"}, AtriSwitch(), AtriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(PRIO).
zero.OnKeywordGroup([]string{"没事", "没关系", "大丈夫", "还好", "不要紧", "没出大问题", "没伤到哪"}, atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(randText(
"当然,我是高性能的嘛~!",
Expand All @@ -178,23 +180,23 @@ func init() { // 插件主体
))
})

zero.OnKeywordGroup([]string{"好吗", "是吗", "行不行", "能不能", "可不可以"}, AtriSwitch(), AtriSleep()).SetBlock(true).SetPriority(PRIO).
zero.OnKeywordGroup([]string{"好吗", "是吗", "行不行", "能不能", "可不可以"}, atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
if rand.Intn(2) == 0 {
ctx.SendChain(randImage("YES.png", "NO.jpg"))
}
})
zero.OnFullMatchGroup([]string{"啊这"}, AtriSwitch(), AtriSleep()).SetBlock(true).SetPriority(PRIO).
zero.OnFullMatchGroup([]string{"啊这"}, atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
if rand.Intn(2) == 0 {
ctx.SendChain(randImage("AZ.jpg", "AZ1.jpg"))
}
})
zero.OnFullMatchGroup([]string{"我好了"}, AtriSwitch(), AtriSleep()).SetBlock(true).SetPriority(PRIO).
zero.OnFullMatchGroup([]string{"我好了"}, atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(randText("不许好!", "憋回去!"))
})
zero.OnFullMatchGroup([]string{"?", "?", "¿"}, AtriSwitch(), AtriSleep()).SetBlock(true).SetPriority(PRIO).
zero.OnFullMatchGroup([]string{"?", "?", "¿"}, atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
switch rand.Intn(5) {
case 0:
Expand All @@ -203,7 +205,7 @@ func init() { // 插件主体
ctx.SendChain(randImage("WH.jpg", "WH1.jpg", "WH2.jpg", "WH3.jpg"))
}
})
zero.OnKeyword("离谱", AtriSwitch(), AtriSleep()).SetBlock(true).SetPriority(PRIO).
zero.OnKeyword("离谱", atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
switch rand.Intn(5) {
case 0:
Expand All @@ -212,7 +214,7 @@ func init() { // 插件主体
ctx.SendChain(randImage("WH.jpg"))
}
})
zero.OnKeyword("答应我", AtriSwitch(), AtriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(PRIO).
zero.OnKeyword("答应我", atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(randText("我无法回应你的请求"))
})
Expand All @@ -225,23 +227,23 @@ func randText(text ...string) message.MessageSegment {

func randImage(file ...string) message.MessageSegment {
length := len(file)
return message.Image(RES + file[rand.Intn(length)])
return message.Image(res + file[rand.Intn(length)])
}

func randRecord(file ...string) message.MessageSegment {
length := len(file)
return message.Record(RES + file[rand.Intn(length)])
return message.Record(res + file[rand.Intn(length)])
}

// AtriSwitch 控制 ATRI 的开关
func AtriSwitch() zero.Rule {
// atriSwitch 控制 ATRI 的开关
func atriSwitch() zero.Rule {
return func(ctx *zero.Ctx) bool {
return ENABLE
return enable
}
}

// AtriSleep 凌晨0点到6点,ATRI 在睡觉,不回应任何请求
func AtriSleep() zero.Rule {
// atriSleep 凌晨0点到6点,ATRI 在睡觉,不回应任何请求
func atriSleep() zero.Rule {
return func(ctx *zero.Ctx) bool {
if now := time.Now().Hour(); now >= 1 && now < 6 {
return false
Expand Down
6 changes: 3 additions & 3 deletions plugin_bilibili/fansDaily.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin_bilibili
package bilibili

import (
"encoding/json"
Expand All @@ -25,12 +25,12 @@ type follower struct {
func init() {
zero.OnFullMatch("/开启粉丝日报", zero.AdminPermission).
Handle(func(ctx *zero.Ctx) {
FansDaily(130591566) // 群号传进去给下面发信息的函数
fansDaily(130591566) // 群号传进去给下面发信息的函数
})
}

// 定时任务每天晚上最后2分钟执行一次
func FansDaily(groupID int64) {
func fansDaily(groupID int64) {
c := cron.New()
_ = c.AddFunc("0 58 23 * * ?", func() { fansData(groupID) })
c.Start()
Expand Down
7 changes: 4 additions & 3 deletions plugin_bilibili/info.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package plugin_bilibili
package bilibili

import (
"io/ioutil"
"net/http"

"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"io/ioutil"
"net/http"
)

// 查成分的
Expand Down
2 changes: 1 addition & 1 deletion plugin_bilibili/live_info.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin_bilibili
package bilibili

import (
"errors"
Expand Down
4 changes: 2 additions & 2 deletions plugin_chat/chat.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
Package plugin_chat
Package chat
对话插件 example
*/
package plugin_chat
package chat

import (
"math/rand"
Expand Down
64 changes: 64 additions & 0 deletions plugin_diana/text.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package diana

import (
"io"
"os"
"time"
)

const (
datapath = "data/Diana"
pbfile = datapath + "/text.pb"
)

var (
compo Composition
ARRAY []string
)

func init() {
go func() {
time.Sleep(time.Second)
err := os.MkdirAll(datapath, 0755)
if err != nil {
panic(err)
}
loadText()
ARRAY = compo.Array
}()
}

func loadText() {
if _, err := os.Stat(pbfile); err == nil || os.IsExist(err) {
f, err := os.Open(pbfile)
if err == nil {
data, err1 := io.ReadAll(f)
if err1 == nil {
if len(data) > 0 {
compo.Unmarshal(data)
}
}
}
}
}

func addText(txt string) error {
if txt != "" {
ARRAY = append(ARRAY, txt)
data, err := compo.Marshal()
if err == nil {
if _, err := os.Stat(datapath); err == nil || os.IsExist(err) {
f, err1 := os.OpenFile(pbfile, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
if err1 != nil {
return err1
} else {
defer f.Close()
_, err2 := f.Write(data)
return err2
}
}
}
return err
}
return nil
}
Loading

0 comments on commit fd64016

Please sign in to comment.