Compare commits

..

21 Commits

Author SHA1 Message Date
fumiama
c22140103f 🐛 小修正 2022-01-10 12:17:39 +08:00
github-actions[bot]
8bd6e40ac8 🎨 改进代码样式 2022-01-09 15:22:17 +00:00
himawari
2ed25c6991 添加签到,引入分数机制 (#101)
* feat:添加签到功能,引入分数机制

* feat:修lint

* fix:加宽

* fix:修lint和加锁

* fix:解决冲突

* fix:二次判断
2022-01-09 23:21:36 +08:00
fumiama
d8991ec016 🐛 启动显示 banner 2022-01-09 23:20:00 +08:00
fumiama
dc9ca1e63f 💩👌 make lint happy 2022-01-09 22:53:22 +08:00
fumiama
7bb3203dfb 🐛 群管全局操作权限错误 2022-01-09 22:20:14 +08:00
fumiama
8ebe9548f7 ️ 优化 abs 2022-01-08 13:56:19 +08:00
fumiama
f90f20d3a8 🙈 同步 data 2022-01-08 11:53:52 +08:00
fumiama
1437e3b323 🎨 小修正 2022-01-07 22:47:32 +08:00
fumiama
d44171de61 ♻️ 🔥 优化 acgimage, 新增 ipv6 分流 2022-01-07 21:57:30 +08:00
fumiama
62a9e413fb 🔖 v1.2.3 2022-01-07 20:10:14 +08:00
fumiama
c12c48dea6 🐛 fix setdata&getdata 2022-01-07 20:07:10 +08:00
github-actions[bot]
7dd81525e4 🎨 改进代码样式 2022-01-07 11:48:23 +00:00
himawari
ca36038bbd 增加小爱回复 (#100)
* fix:去掉count,修sql

* feat:增加小爱回复

* fix:修一下lint

* fix:修一下lint

* fix:修一下lint

* fix:修一下lint

* fix:修改设置回复模式

* fix:修lint

Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
2022-01-07 19:47:35 +08:00
fumiama
ca2f674696 更新 md5 服务器域名 2022-01-06 21:09:34 +08:00
fumiama
8acf9b817f ✏️ 修复 cd valid 判断 2022-01-06 12:40:48 +08:00
fumiama
2dc1fbde96 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2022-01-06 12:26:08 +08:00
fumiama
919651a2b3 💩👌 make lint happy 2022-01-06 12:25:56 +08:00
himawari
19b55a574f fix:去掉count,修sql (#99) 2022-01-03 23:13:24 +08:00
fumiama
a6ab7de475 ⬆️ 更新 摸鱼 元旦 2022-01-03 10:54:59 +08:00
fumiama
2ff229e9d9 ⚰️ 简化 getdata 2022-01-03 01:00:35 +08:00
26 changed files with 882 additions and 335 deletions

View File

@@ -197,8 +197,9 @@ zerobot -h -t token -u url [-d|w] [-g 监听地址:端口] qq1 qq2 qq3 ...
- [x] 搜卡[xxxx]
- [x] [卡组代码xxx]
-更多搜卡指令参数https://hs.fbigame.com/misc/searchhelp
- **青云客** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_qingyunke"`
- **人工智能回复** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_reply"`
- [x] @Bot 任意文本(任意一句话回复)
- [x] 设置回复模式[青云客|小爱]
- **关键字搜图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_image_finder"`
- [x] 来张 [xxx]
- **拼音首字母释义工具** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_nbnhhsh"`
@@ -241,6 +242,9 @@ zerobot -h -t token -u url [-d|w] [-g 监听地址:端口] qq1 qq2 qq3 ...
- **cp短打** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_cpstory"`
- [x] 组cp[@xxx][@xxx]
- [x] 组cp大老师 雪乃
- **签到得分** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_score"`
- [x] 签到
- [x] 获得签到背景[@xxx]|获得签到背景
- **TODO...**
## 使用方法

View File

@@ -10,6 +10,7 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/ZeroBot-Plugin/utils/math"
"github.com/FloatTech/ZeroBot-Plugin/utils/process"
)
@@ -87,7 +88,7 @@ func isValidToken(tok string) (yes bool) {
if err == nil {
timebytes := make([]byte, 1, 8)
timebytes = append(timebytes, b14.Decode(s)...)
yes = time.Now().Unix()-int64(binary.BigEndian.Uint64(timebytes)) < 10
yes = math.Abs64(time.Now().Unix()-int64(binary.BigEndian.Uint64(timebytes))) < 10
}
return
}

View File

@@ -211,20 +211,11 @@ func (m *Control) GetData(gid int64) int64 {
var c grpcfg
var err error
log.Debugln("[control] IsEnabledIn recv gid =", gid)
if gid != 0 {
m.RLock()
err = db.Find(m.service, &c, "WHERE gid = "+strconv.FormatInt(gid, 10))
m.RUnlock()
if err == nil && gid == c.GroupID {
log.Debugf("[control] plugin %s of grp %d : %x", m.service, c.GroupID, c.Disable>>1)
return c.Disable >> 1
}
}
m.RLock()
err = db.Find(m.service, &c, "WHERE gid = 0")
err = db.Find(m.service, &c, "WHERE gid = "+strconv.FormatInt(gid, 10))
m.RUnlock()
if err == nil && c.GroupID == 0 {
log.Debugf("[control] plugin %s of all : %x", m.service, c.Disable>>1)
if err == nil && gid == c.GroupID {
log.Debugf("[control] plugin %s of grp %d : 0x%x", m.service, c.GroupID, c.Disable>>1)
return c.Disable >> 1
}
return 0
@@ -242,8 +233,9 @@ func (m *Control) SetData(groupID int64, data int64) error {
c.Disable = 1
}
}
c.Disable &= 1
c.Disable |= data << 1
log.Debugf("[control] set plugin %s of all : %x", m.service, data)
log.Debugf("[control] set plugin %s of grp %d : 0x%x", m.service, c.GroupID, data)
m.Lock()
err = db.Insert(m.service, &c)
m.Unlock()
@@ -312,7 +304,6 @@ func init() {
hasinit = true
zero.OnCommandGroup([]string{
"启用", "enable", "禁用", "disable",
"全局启用", "enableall", "全局禁用", "disableall",
}, userOrGrpAdmin).SetBlock(true).FirstPriority().Handle(func(ctx *zero.Ctx) {
model := extension.CommandModel{}
_ = ctx.Parse(&model)
@@ -326,9 +317,6 @@ func init() {
// 个人用户
grp = -ctx.Event.UserID
}
if strings.Contains(model.Command, "全局") || strings.Contains(model.Command, "all") {
grp = 0
}
if strings.Contains(model.Command, "启用") || strings.Contains(model.Command, "enable") {
service.Enable(grp)
ctx.SendChain(message.Text("已启用服务: " + model.Args))
@@ -338,6 +326,25 @@ func init() {
}
})
zero.OnCommandGroup([]string{
"全局启用", "enableall", "全局禁用", "disableall",
}, zero.OnlyToMe, zero.SuperUserPermission).SetBlock(true).FirstPriority().Handle(func(ctx *zero.Ctx) {
model := extension.CommandModel{}
_ = ctx.Parse(&model)
service, ok := Lookup(model.Args)
if !ok {
ctx.SendChain(message.Text("没有找到指定服务!"))
return
}
if strings.Contains(model.Command, "启用") || strings.Contains(model.Command, "enable") {
service.Enable(0)
ctx.SendChain(message.Text("已全局启用服务: " + model.Args))
} else {
service.Disable(0)
ctx.SendChain(message.Text("已全局禁用服务: " + model.Args))
}
})
zero.OnCommandGroup([]string{"还原", "reset"}, userOrGrpAdmin).SetBlock(true).FirstPriority().Handle(func(ctx *zero.Ctx) {
model := extension.CommandModel{}
_ = ctx.Parse(&model)
@@ -357,7 +364,6 @@ func init() {
zero.OnCommandGroup([]string{
"禁止", "ban", "允许", "permit",
"全局禁止", "banall", "全局允许", "permitall",
}, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).FirstPriority().Handle(func(ctx *zero.Ctx) {
model := extension.CommandModel{}
_ = ctx.Parse(&model)
@@ -369,9 +375,6 @@ func init() {
return
}
grp := ctx.Event.GroupID
if strings.Contains(model.Command, "全局") || strings.Contains(model.Command, "all") {
grp = 0
}
msg := "**" + args[0] + "报告**"
if strings.Contains(model.Command, "允许") || strings.Contains(model.Command, "permit") {
for _, usr := range args[1:] {
@@ -396,6 +399,42 @@ func init() {
ctx.SendChain(message.Text("参数错误!"))
})
zero.OnCommandGroup([]string{
"全局禁止", "banall", "全局允许", "permitall",
}, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).FirstPriority().Handle(func(ctx *zero.Ctx) {
model := extension.CommandModel{}
_ = ctx.Parse(&model)
args := strings.Split(model.Args, " ")
if len(args) >= 2 {
service, ok := Lookup(args[0])
if !ok {
ctx.SendChain(message.Text("没有找到指定服务!"))
return
}
msg := "**" + args[0] + "全局报告**"
if strings.Contains(model.Command, "允许") || strings.Contains(model.Command, "permit") {
for _, usr := range args[1:] {
uid, err := strconv.ParseInt(usr, 10, 64)
if err == nil {
service.Permit(uid, 0)
msg += "\n+ 已允许" + usr
}
}
} else {
for _, usr := range args[1:] {
uid, err := strconv.ParseInt(usr, 10, 64)
if err == nil {
service.Ban(uid, 0)
msg += "\n- 已禁止" + usr
}
}
}
ctx.SendChain(message.Text(msg))
return
}
ctx.SendChain(message.Text("参数错误!"))
})
zero.OnCommandGroup([]string{"用法", "usage"}, userOrGrpAdmin).SetBlock(true).FirstPriority().
Handle(func(ctx *zero.Ctx) {
model := extension.CommandModel{}

2
data

Submodule data updated: 6749b772b9...fc5b776266

4
go.mod
View File

@@ -3,7 +3,7 @@ module github.com/FloatTech/ZeroBot-Plugin
go 1.17
require (
github.com/FloatTech/AnimeAPI v1.1.11
github.com/FloatTech/AnimeAPI v1.1.12
github.com/FloatTech/ZeroBot-Plugin-Gif v0.2.4
github.com/FloatTech/bot-manager v1.0.1-0.20211112011524-85b9895271ed
github.com/antchfx/htmlquery v1.2.4
@@ -62,7 +62,7 @@ require (
github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
golang.org/x/mod v0.5.1 // indirect
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect
golang.org/x/net v0.0.0-20220105145211-5b0dc2dfae98 // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/tools v0.1.8 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect

44
go.sum
View File

@@ -1,6 +1,8 @@
github.com/FloatTech/AnimeAPI v1.1.9/go.mod h1:CC+vF30UGBlcIUxwFOcXIEHoJ4r7c5x2iLQsnUCVdDI=
github.com/FloatTech/AnimeAPI v1.1.11 h1:uuV4v5qweh0mI0E2KMiG5XGt0pKboV/EFAlIfSJxIi8=
github.com/FloatTech/AnimeAPI v1.1.11/go.mod h1:CC+vF30UGBlcIUxwFOcXIEHoJ4r7c5x2iLQsnUCVdDI=
github.com/FloatTech/AnimeAPI v1.1.12 h1:tEIAYumjti+FXYw5dhANU9lpoHY7i/sLm96Ly6kPeLE=
github.com/FloatTech/AnimeAPI v1.1.12/go.mod h1:CC+vF30UGBlcIUxwFOcXIEHoJ4r7c5x2iLQsnUCVdDI=
github.com/FloatTech/ZeroBot-Plugin v1.1.5/go.mod h1:kWuUARvU7gs4xLggi8Sy37ja2GRL6k0X6kewe5TiZRs=
github.com/FloatTech/ZeroBot-Plugin-Gif v0.2.4 h1:WW0BmmLLqAg+m6qGkrKbsfSIm91fkj3/udt3R7Myodo=
github.com/FloatTech/ZeroBot-Plugin-Gif v0.2.4/go.mod h1:W7ag6hml1pZTNzRXKU74OMr6rS8awQKSU+o2g7Gj4O0=
@@ -14,11 +16,9 @@ github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb/go.mod h1:imVKbfKqqe
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/antchfx/htmlquery v1.2.3 h1:sP3NFDneHx2stfNXCKbhHFo8XgNjCACnU/4AO5gWz6M=
github.com/antchfx/htmlquery v1.2.3/go.mod h1:B0ABL+F5irhhMWg54ymEZinzMSi0Kt3I2if0BLYa3V0=
github.com/antchfx/htmlquery v1.2.4 h1:qLteofCMe/KGovBI6SQgmou2QNyedFUW+pE+BpeZ494=
github.com/antchfx/htmlquery v1.2.4/go.mod h1:2xO6iu3EVWs7R2JYqBbp8YzG50gj/ofqs5/0VZoDZLc=
github.com/antchfx/xpath v1.1.6 h1:6sVh6hB5T6phw1pFpHRQ+C4bd8sNI+O58flqtg7h0R0=
github.com/antchfx/xpath v1.1.6/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk=
github.com/antchfx/xpath v1.2.0 h1:mbwv7co+x0RwgeGAOHdrKy89GvHaGvxxBtPK0uF9Zr8=
github.com/antchfx/xpath v1.2.0/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs=
@@ -60,15 +60,12 @@ github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU=
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
github.com/go-playground/validator/v10 v10.10.0 h1:I7mrTYv78z8k8VXa/qJlOlEXn/nBh+BF8dHX5nt/dr0=
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
@@ -78,7 +75,6 @@ github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZ
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
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/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
@@ -106,7 +102,6 @@ github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkr
github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M=
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
@@ -116,11 +111,12 @@ github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47e
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
@@ -130,23 +126,19 @@ github.com/logoove/sqlite v1.13.0 h1:XM7QKK9R3tm8o7bI75R3zmwYBFQ5S3Jqg+XCaqsAMQQ
github.com/logoove/sqlite v1.13.0/go.mod h1:MRpE/o3qQhT7AgfIdnBue5c63+//xT+KXV0gHeVAUAg=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU=
github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA=
github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2-0.20210109003243-333559e1834b h1:6Xjqolv/0DDdUqlpnsTomXQvjvvkz7Ux7TcMALvozEw=
github.com/modern-go/reflect2 v1.0.2-0.20210109003243-333559e1834b/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
@@ -170,11 +162,10 @@ github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/shirou/gopsutil v3.21.8+incompatible h1:sh0foI8tMRlCidUJR+KzqWYWxrkuuPIGiO6Vp+KXdCU=
github.com/shirou/gopsutil v3.21.8+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil/v3 v3.21.11 h1:d5tOAP5+bmJ8Hf2+4bxOSkQ/64+sjEbjU9nSW9nJgG0=
github.com/shirou/gopsutil/v3 v3.21.11/go.mod h1:BToYZVTlSVlfazpDDYFnsVZLaoRG+g8ufT6fPQLdJzA=
github.com/shirou/gopsutil/v3 v3.21.12 h1:VoGxEW2hpmz0Vt3wUvHIl9fquzYLNpVpgNNB7pGJimA=
github.com/shirou/gopsutil/v3 v3.21.12/go.mod h1:BToYZVTlSVlfazpDDYFnsVZLaoRG+g8ufT6fPQLdJzA=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
@@ -207,11 +198,9 @@ github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ=
github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8=
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go v1.2.6 h1:tGiWC9HENWE2tqYycIqFTNorMmFRVhNwCpDOpWqnk8E=
github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0=
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ=
github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw=
@@ -222,13 +211,13 @@ github.com/wdvxdr1123/ZeroBot v1.3.2/go.mod h1:i2DIqQjtjE+3gvVi9r9sc+QpNaUuyTXx/
github.com/wdvxdr1123/ZeroBot v1.4.1 h1:fk/8RH2D1gB3YeC1eI/SZi/kG31Rh7Z8lAiDc60VZFM=
github.com/wdvxdr1123/ZeroBot v1.4.1/go.mod h1:7t9m4vDZPwWAmzKlhP6IvUoisOIiqNdm/3AJgiY3+ew=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/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-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M=
@@ -237,7 +226,6 @@ golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+o
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
@@ -250,10 +238,10 @@ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/
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-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f h1:hEYJvxw1lSnWIl8X9ofsYMklzaDs90JI2az5YMd4fPM=
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220105145211-5b0dc2dfae98 h1:+6WJMRLHlD7X7frgp7TUZ36RnQzSf9wVVTNakEp+nqY=
golang.org/x/net v0.0.0-20220105145211-5b0dc2dfae98/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
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-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -277,21 +265,19 @@ golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c h1:taxlMj0D/1sOAuv/CbSD+MMDof2vbyPTqz5FNYKpXt8=
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
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/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
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-20201124115921-2c860bdd6e78 h1:M8tBwCtWD/cZV9DZpFYRUgaymAYAr+aIUTWzDaM3uPs=
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.8 h1:P1HhGGuLW4aAclzjtmJdf0mJOjVUZUzOTqkAkWL+l6w=
golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
@@ -304,7 +290,6 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
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 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
@@ -314,19 +299,17 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
lukechampine.com/uint128 v1.1.1 h1:pnxCASz787iMf+02ssImqk6OLt+Z5QHMoZyUXR4z6JU=
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
modernc.org/cc/v3 v3.33.6/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.33.9/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.33.11/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.34.0 h1:dFhZc/HKR3qp92sYQxKRRaDMz+sr1bwcFD+m7LSCrAs=
modernc.org/cc/v3 v3.34.0/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.0/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.4/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
@@ -345,7 +328,6 @@ modernc.org/ccgo/v3 v3.9.5/go.mod h1:umuo2EP2oDSBnD3ckjaVUXMrmeAw8C8OSICVa0iFf60
modernc.org/ccgo/v3 v3.10.0/go.mod h1:c0yBmkRFi7uW4J7fwx/JiijwOjeAeR2NoSaRVFPmjMw=
modernc.org/ccgo/v3 v3.11.0/go.mod h1:dGNposbDp9TOZ/1KBxghxtUp/bzErD0/0QW4hhSaBMI=
modernc.org/ccgo/v3 v3.11.1/go.mod h1:lWHxfsn13L3f7hgGsGlU28D9eUOf6y3ZYHKoPaKU0ag=
modernc.org/ccgo/v3 v3.11.2 h1:gqa8PQ2v7SjrhHCgxUO5dzoAJWSLAveJqZTNkPCN0kc=
modernc.org/ccgo/v3 v3.11.2/go.mod h1:6kii3AptTDI+nUrM9RFBoIEUEisSWCbdczD9ZwQH2FE=
modernc.org/ccgo/v3 v3.11.3/go.mod h1:0oHunRBMBiXOKdaglfMlRPBALQqsfrCKXgw9okQ3GEw=
modernc.org/ccgo/v3 v3.12.4/go.mod h1:Bk+m6m2tsooJchP/Yk5ji56cClmN6R1cqc9o/YtbgBQ=
@@ -385,13 +367,14 @@ modernc.org/ccgo/v3 v3.12.95/go.mod h1:ZcLyvtocXYi8uF+9Ebm3G8EF8HNY5hGomBqthDp4e
modernc.org/ccgo/v3 v3.13.1/go.mod h1:aBYVOUfIlcSnrsRVU8VRS35y2DIfpgkmVkYZ0tpIXi4=
modernc.org/ccgo/v3 v3.14.0 h1:Zr1Ny9+7r5yAiXpBdgp8XiXqkNA4ARrRphHGHVXeAp0=
modernc.org/ccgo/v3 v3.14.0/go.mod h1:hBrkiBlUwvr5vV/ZH9YzXIp982jKE8Ek8tR1ytoAL6Q=
modernc.org/ccorpus v1.11.1 h1:K0qPfpVG1MJh5BYazccnmhywH4zHuOgJXgbjzyp6dWA=
modernc.org/ccorpus v1.11.1/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ=
modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM=
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
modernc.org/libc v1.9.8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
modernc.org/libc v1.9.11/go.mod h1:NyF3tsA5ArIjJ83XB0JlqhjTabTCHm9aX4XMPHyQn0Q=
modernc.org/libc v1.11.0/go.mod h1:2lOfPmj7cz+g1MrPNmX65QCzVxgNq2C5o0jdLY2gAYg=
modernc.org/libc v1.11.2/go.mod h1:ioIyrl3ETkugDO3SGZ+6EOKvlP3zSOycUETe4XM4n8M=
modernc.org/libc v1.11.3 h1:q//spBhqp23lC/if8/o8hlyET57P8mCZqrqftzT2WmY=
modernc.org/libc v1.11.3/go.mod h1:k3HDCP95A6U111Q5TmG3nAyUcp3kR5YFZTeDS9v8vSU=
modernc.org/libc v1.11.5/go.mod h1:k3HDCP95A6U111Q5TmG3nAyUcp3kR5YFZTeDS9v8vSU=
modernc.org/libc v1.11.6/go.mod h1:ddqmzR6p5i4jIGK1d/EiSw97LBcE3dK24QEwCFvgNgE=
@@ -443,7 +426,6 @@ modernc.org/memory v1.0.5 h1:XRch8trV7GgvTec2i7jc33YlUI0RKVDBvZ5eZ5m8y14=
modernc.org/memory v1.0.5/go.mod h1:B7OYswTRnfGg+4tDH1t1OeUNnsy2viGTdME4tzd+IjM=
modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A=
modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/sqlite v1.13.0 h1:cwhUj0jTBgPjk/demWheV+T6xi6ifTfsGIFKFq0g3Ck=
modernc.org/sqlite v1.13.0/go.mod h1:2qO/6jZJrcQaxFUHxOwa6Q6WfiGSsiVj6GXX0Ker+Jg=
modernc.org/sqlite v1.14.3 h1:psrTwgpEujgWEP3FNdsC9yNh5tSeA77U0GeWhHH4XmQ=
modernc.org/sqlite v1.14.3/go.mod h1:xMpicS1i2MJ4C8+Ap0vYBqTwYfpFvdnPE6brbFOtV2Y=

13
main.go
View File

@@ -13,9 +13,9 @@ import (
// webctrl "github.com/FloatTech/ZeroBot-Plugin/control/web" // web 后端控制
// 词库类
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_atri" // ATRI词库
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_chat" // 基础词库
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_qingyunke" // 青云客
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_reply" // 人工智能回复
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_atri" // ATRI词库
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_chat" // 基础词库
// 实用类
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_b14" // base16384加解密
@@ -47,6 +47,7 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_novel" // 铅笔小说网搜索
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_omikuji" // 浅草寺求签
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_reborn" // 投胎
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_score" // 分数
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shadiao" // 沙雕app
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shindan" // 测定
@@ -77,14 +78,14 @@ import (
var (
contents = []string{
"* OneBot + ZeroBot + Golang",
"* Version 1.2.2 - 2021-12-13 21:22:45 +0800 CST",
"* Version 1.2.3 - 2022-01-07 20:09:30 +0800 CST",
"* Copyright © 2020 - 2021 FloatTech. All Rights Reserved.",
"* Project: https://github.com/FloatTech/ZeroBot-Plugin",
}
banner = strings.Join(contents, "\n")
token *string
url *string
reg = registry.NewRegReader("reilia.eastasia.azurecontainer.io:32664", "fumiama")
reg = registry.NewRegReader("reilia.fumiama.top:32664", "fumiama")
)
func init() {
@@ -142,7 +143,7 @@ func getKanban() string {
}
func main() {
// printBanner()
printBanner()
// 帮助
zero.OnFullMatchGroup([]string{"/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).FirstPriority().
Handle(func(ctx *zero.Ctx) {

View File

@@ -3,7 +3,6 @@ package acgimage
import (
"net/url"
"strconv"
"strings"
"time"
@@ -14,17 +13,16 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
"github.com/FloatTech/ZeroBot-Plugin/utils/file"
"github.com/FloatTech/ZeroBot-Plugin/utils/web"
)
const (
lolipxy = "https://sayuri.fumiama.top/dice?class=0&loli=true&r18=true"
apihead = "https://sayuri.fumiama.top/img?path="
lolipxy = "https://sayuri.fumiama.top/dice?class=0&loli=true&r18=true"
apihead = "https://sayuri.fumiama.top/img?path="
apiheadv6 = "http://aikae.v6.army:62002/img?arg=get&name="
)
var (
datapath = file.BOTPATH + "/data/acgimage/"
cacheuri = "file:///" + datapath + "cache"
// r18有一定保护一般不会发出图片
randapi = "&loli=true&r18=true"
msgof = make(map[int64]int64)
@@ -33,8 +31,6 @@ var (
)
func init() { // 插件主体
// 初始化 classify
classify.Init(datapath)
engine := control.Register("acgimage", &control.Options{
DisableOnDefault: false,
Help: "随机图片与AI点评\n" +
@@ -57,14 +53,12 @@ func init() { // 插件主体
// 有保护的随机图片
engine.OnFullMatch("随机图片", zero.OnlyGroup).SetBlock(true).SetPriority(24).
Handle(func(ctx *zero.Ctx) {
if classify.CanVisit(5) && limit.Load(ctx.Event.UserID).Acquire() {
go func() {
class, lastvisit, dhash, comment := classify.Classify(randapi, false)
replyClass(ctx, dhash, class, false, lastvisit, comment)
}()
} else {
ctx.SendChain(message.Text("你太快啦!"))
if limit.Load(ctx.Event.UserID).Acquire() {
class, dhash, comment, _ := classify.Classify(randapi, true)
replyClass(ctx, class, dhash, comment, false)
return
}
ctx.SendChain(message.Text("你太快啦!"))
})
// 直接随机图片无r18保护后果自负。如果出r18图可尽快通过发送"太涩了"撤回
engine.OnFullMatch("直接随机", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(24).
@@ -86,24 +80,31 @@ func init() { // 插件主体
// 撤回最后的直接随机图片
engine.OnFullMatch("太涩了").SetBlock(true).SetPriority(24).
Handle(func(ctx *zero.Ctx) {
go cancel(ctx)
msg, ok := msgof[ctx.Event.GroupID]
if ok {
ctx.DeleteMessage(msg)
delete(msgof, ctx.Event.GroupID)
}
})
// 上传一张图进行评价
engine.OnKeywordGroup([]string{"评价图片"}, zero.OnlyGroup, picture.CmdMatch, picture.MustGiven).SetBlock(true).SetPriority(24).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text("少女祈祷中..."))
for _, url := range ctx.State["image_url"].([]string) {
go func(target string) {
class, lastvisit, dhash, comment := classify.Classify(target, true)
replyClass(ctx, dhash, class, true, lastvisit, comment)
}(url)
class, dhash, comment, _ := classify.Classify(url, true)
replyClass(ctx, class, dhash, comment, true)
break
}
})
engine.OnRegex(`^给你点提示哦:(.*)$`, zero.OnlyPrivate).SetBlock(true).SetPriority(20).
Handle(func(ctx *zero.Ctx) {
dhash := ctx.State["regex_matched"].([]string)[1]
if len(dhash) == 5*3 {
ctx.SendChain(message.Image(apihead + dhash))
if web.IsSupportIPv6 {
ctx.SendChain(message.Image(apiheadv6 + dhash + ".webp"))
} else {
ctx.SendChain(message.Image(apihead + dhash))
}
}
})
}
@@ -112,32 +113,32 @@ func setLastMsg(id int64, msg int64) {
msgof[id] = msg
}
func cancel(ctx *zero.Ctx) {
msg, ok := msgof[ctx.Event.GroupID]
if ok {
ctx.DeleteMessage(msg)
delete(msgof, ctx.Event.GroupID)
func replyClass(ctx *zero.Ctx, class int, dhash string, comment string, isupload bool) {
b14, err := url.QueryUnescape(dhash)
if err != nil {
return
}
}
func replyClass(ctx *zero.Ctx, dhash string, class int, noimg bool, lv int64, comment string) {
img := message.Image(cacheuri + strconv.FormatInt(lv, 10))
if class > 5 {
if dhash != "" && !noimg {
b14, err3 := url.QueryUnescape(dhash)
if err3 == nil {
ctx.SendChain(message.Text(comment + "\n给你点提示哦" + b14))
ctx.Event.GroupID = 0
ctx.SendChain(img)
}
} else {
ctx.SendChain(message.Text(comment))
}
var img message.MessageSegment
if web.IsSupportIPv6 {
img = message.Image(apiheadv6 + dhash + ".webp")
} else {
if !noimg {
ctx.SendChain(img, message.Text(comment))
} else {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(comment))
}
img = message.Image(apihead + dhash)
}
if class > 5 {
if dhash != "" && !isupload {
ctx.SendChain(message.Text(comment + "\n给你点提示哦" + b14))
ctx.Event.GroupID = 0
ctx.SendChain(img)
return
}
ctx.SendChain(message.Text(comment))
return
}
if isupload {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(comment))
return
}
ctx.SendChain(img, message.Text(comment))
}

149
plugin_ai_reply/ai_reply.go Normal file
View File

@@ -0,0 +1,149 @@
// Package aireply 人工智能回复
package aireply
import (
"errors"
"math/rand"
"time"
log "github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
)
var (
bucket = rate.NewManager(time.Minute, 20) // 青云客接口回复
engine = control.Register(serviceName, &control.Options{
DisableOnDefault: false,
Help: "人工智能回复\n" +
"- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客|小爱]\n- ",
})
modeMap = map[string]int64{"青云客": 1, "小爱": 2}
)
const (
serviceName = "aireply"
qykURL = "http://api.qingyunke.com/api.php?key=free&appid=0&msg=%s"
qykBotName = "菲菲"
xiaoaiURL = "http://81.70.100.130/api/xiaoai.php?msg=%s&n=text"
xiaoaiBotName = "小爱"
prio = 256
)
// AIReply 公用智能回复类
type AIReply interface {
// DealQuestion 把椛椛替换为各api接口的bot名字
DealQuestion(preMsg string) (msg string)
// GetReply 取得回复消息
GetReply(msg string) (reply string)
// DealReply 处理回复消息
DealReply(reply string) (textReply string, faceReply int)
}
// NewAIReply 智能回复简单工厂
func NewAIReply(mode int64) AIReply {
if mode == 1 {
return &QYKReply{}
} else if mode == 2 {
return &XiaoAiReply{}
}
return &QYKReply{}
}
func init() { // 插件主体
// 回复 @和包括名字
engine.OnMessage(zero.OnlyToMe).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
aireply := NewAIReply(GetReplyMode(ctx))
if !bucket.Load(ctx.Event.UserID).Acquire() {
// 频繁触发,不回复
return
}
msg := ctx.ExtractPlainText()
// 把消息里的椛椛替换成对应接口机器人的名字
msg = aireply.DealQuestion(msg)
reply := aireply.GetReply(msg)
// 挑出 face 表情
textReply, faceReply := aireply.DealReply(reply)
// 回复
time.Sleep(time.Second * 1)
if ctx.Event.MessageType == "group" {
if faceReply != -1 {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(textReply), message.Face(faceReply))
} else {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(textReply))
}
}
if ctx.Event.MessageType == "private" {
if faceReply != -1 {
ctx.SendChain(message.Text(textReply), message.Face(faceReply))
} else {
ctx.SendChain(message.Text(textReply))
}
}
})
engine.OnPrefix(`设置回复模式`).SetBlock(true).SetPriority(20).
Handle(func(ctx *zero.Ctx) {
param := ctx.State["args"].(string)
switch param {
case "青云客":
if err := setReplyMode(ctx, modeMap["青云客"]); err != nil {
log.Errorln("[aireply]:", err)
}
ctx.SendChain(message.Text("设置为青云客回复"))
case "小爱":
if err := setReplyMode(ctx, modeMap["小爱"]); err != nil {
log.Errorln("[aireply]:", err)
}
ctx.SendChain(message.Text("设置为小爱回复"))
default:
ctx.SendChain(message.Text("设置失败"))
}
})
}
func setReplyMode(ctx *zero.Ctx, mode int64) error {
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
m, ok := control.Lookup(serviceName)
if ok {
return m.SetData(gid, mode)
}
return errors.New("no such plugin")
}
// GetReplyMode 取得回复模式
func GetReplyMode(ctx *zero.Ctx) (mode int64) {
gid := ctx.Event.GroupID
if gid == 0 {
gid = -ctx.Event.UserID
}
m, ok := control.Lookup(serviceName)
if ok {
mode = m.GetData(gid)
}
return mode
}
func getAgent() string {
agent := [...]string{
"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0",
"Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; en) Presto/2.8.131 Version/11.11",
"Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)",
"Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; The World)",
"User-Agent,Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50",
"User-Agent, Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)",
"User-Agent,Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50",
}
r := rand.New(rand.NewSource(time.Now().UnixNano()))
len1 := len(agent)
return agent[r.Intn(len1)]
}

View File

@@ -1,4 +1,4 @@
package qingyunke
package aireply
// TODO: 待优化

View File

@@ -0,0 +1,69 @@
package aireply
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"regexp"
"strconv"
"strings"
log "github.com/sirupsen/logrus"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
)
// QYKReply 青云客回复类
type QYKReply struct{}
// DealQuestion 把椛椛替换为菲菲
func (*QYKReply) DealQuestion(preMsg string) (msg string) {
msg = strings.ReplaceAll(preMsg, zero.BotConfig.NickName[0], qykBotName)
return msg
}
// GetReply 取得回复消息
func (*QYKReply) GetReply(msg string) (reply string) {
u := fmt.Sprintf(qykURL, url.QueryEscape(msg))
client := &http.Client{}
req, err := http.NewRequest("GET", u, nil)
if err != nil {
log.Errorln("[aireply-qingyunke]:", err)
return ""
}
// 自定义Header
req.Header.Set("User-Agent", getAgent())
req.Header.Set("Connection", "keep-alive")
req.Header.Set("Host", "api.qingyunke.com")
resp, err := client.Do(req)
if err != nil {
log.Errorln("[aireply-qingyunke]:", err)
return
}
defer resp.Body.Close()
bytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Errorln("[aireply-qingyunke]:", err)
return
}
reply = gjson.Get(helper.BytesToString(bytes), "content").String()
log.Println("reply:", reply)
return
}
// DealReply 处理回复消息
func (*QYKReply) DealReply(reply string) (textReply string, faceReply int) {
reg := regexp.MustCompile(`\{face:(\d+)\}(.*)`)
faceReply = -1
if reg.MatchString(reply) {
faceReply, _ = strconv.Atoi(reg.FindStringSubmatch(reply)[1])
textReply = reg.FindStringSubmatch(reply)[2]
} else {
textReply = reply
}
textReply = strings.ReplaceAll(textReply, qykBotName, zero.BotConfig.NickName[0])
textReply = strings.ReplaceAll(textReply, "{br}", "\n")
return
}

62
plugin_ai_reply/xiaoai.go Normal file
View File

@@ -0,0 +1,62 @@
package aireply
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
log "github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
)
// XiaoAiReply 小爱回复类
type XiaoAiReply struct{}
// DealQuestion 把椛椛替换为小爱
func (*XiaoAiReply) DealQuestion(preMsg string) (msg string) {
msg = strings.ReplaceAll(preMsg, zero.BotConfig.NickName[0], xiaoaiBotName)
return msg
}
// GetReply 取得回复消息
func (*XiaoAiReply) GetReply(msg string) (reply string) {
u := fmt.Sprintf(xiaoaiURL, url.QueryEscape(msg))
client := &http.Client{}
req, err := http.NewRequest("GET", u, nil)
if err != nil {
log.Errorln("[aireply-xiaoai]:", err)
return ""
}
// 自定义Header
req.Header.Set("User-Agent", getAgent())
req.Header.Set("Connection", "keep-alive")
req.Header.Set("Host", "81.70.100.130")
resp, err := client.Do(req)
if err != nil {
log.Errorln("[aireply-xiaoai]:", err)
return
}
defer resp.Body.Close()
bytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Errorln("[aireply-xiaoai]:", err)
return
}
reply = helper.BytesToString(bytes)
log.Println("reply:", reply)
return
}
// DealReply 处理回复消息
func (*XiaoAiReply) DealReply(reply string) (textReply string, faceReply int) {
textReply = strings.ReplaceAll(reply, xiaoaiBotName, zero.BotConfig.NickName[0])
if textReply == "" {
textReply = zero.BotConfig.NickName[0] + "听不懂你的话了,能再说一遍吗"
}
textReply = strings.ReplaceAll(textReply, "小米智能助理", "电子宠物")
faceReply = -1
return
}

View File

@@ -15,13 +15,13 @@ func firstWeek(date *time.Time, week time.Weekday) (d time.Time) {
return
}
func (ts *Timer) nextWakeTime() (date time.Time) {
func (t *Timer) nextWakeTime() (date time.Time) {
date = time.Now()
m := ts.Month()
d := ts.Day()
h := ts.Hour()
mn := ts.Minute()
w := ts.Week()
m := t.Month()
d := t.Day()
h := t.Hour()
mn := t.Minute()
w := t.Week()
var unit time.Duration
logrus.Debugln("[timer] unit init:", unit)
if mn >= 0 {
@@ -74,35 +74,35 @@ func (ts *Timer) nextWakeTime() (date time.Time) {
}
switch stable {
case 0b0101:
if ts.Day() != time.Now().Day() || ts.Month() != time.Now().Month() {
if t.Day() != time.Now().Day() || t.Month() != time.Now().Month() {
h = 0
}
case 0b1001:
if ts.Month() != time.Now().Month() {
if t.Month() != time.Now().Month() {
d = 0
}
case 0b0001:
if ts.Month() != time.Now().Month() {
if t.Month() != time.Now().Month() {
d = 0
h = 0
}
}
logrus.Debugln("[timer] stable:", stable)
logrus.Debugln("[timer] m:", m, "d:", d, "h:", h, "mn:", mn, "w:", w)
date = time.Date(date.Year(), time.Month(m), d, h, mn, date.Second(), date.Nanosecond(), date.Location())
date = time.Date(date.Year(), m, d, h, mn, date.Second(), date.Nanosecond(), date.Location())
logrus.Debugln("[timer] date original:", date)
if unit > 0 {
date = date.Add(unit)
}
logrus.Debugln("[timer] date after add:", date)
if time.Until(date) <= 0 {
if ts.Month() < 0 {
if ts.Day() > 0 || (ts.Day() == 0 && ts.Week() >= 0) {
if t.Month() < 0 {
if t.Day() > 0 || (t.Day() == 0 && t.Week() >= 0) {
date = date.AddDate(0, 1, 0)
} else if ts.Day() < 0 || ts.Week() < 0 {
if ts.Hour() > 0 {
} else if t.Day() < 0 || t.Week() < 0 {
if t.Hour() > 0 {
date = date.AddDate(0, 0, 1)
} else if ts.Minute() > 0 {
} else if t.Minute() > 0 {
date = date.Add(time.Hour)
}
}
@@ -140,7 +140,7 @@ func (ts *Timer) nextWakeTime() (date time.Time) {
default:
date = date.AddDate(1, 0, 0)
}
date = firstWeek(&date, time.Weekday(w))
date = firstWeek(&date, w)
}
logrus.Debugln("[timer] date after s2:", date)
if time.Until(date) <= 0 {
@@ -149,14 +149,14 @@ func (ts *Timer) nextWakeTime() (date time.Time) {
return date
}
func (ts *Timer) judgeHM() {
if ts.Hour() < 0 || ts.Hour() == time.Now().Hour() {
if ts.Minute() < 0 || ts.Minute() == time.Now().Minute() {
if ts.SelfID != 0 {
ts.sendmsg(ts.GrpID, zero.GetBot(ts.SelfID))
func (t *Timer) judgeHM() {
if t.Hour() < 0 || t.Hour() == time.Now().Hour() {
if t.Minute() < 0 || t.Minute() == time.Now().Minute() {
if t.SelfID != 0 {
t.sendmsg(t.GrpID, zero.GetBot(t.SelfID))
} else {
zero.RangeBot(func(id int64, ctx *zero.Ctx) (_ bool) {
ts.sendmsg(ts.GrpID, ctx)
t.sendmsg(t.GrpID, ctx)
return
})
}

View File

@@ -19,8 +19,8 @@ import (
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/ZeroBot-Plugin/control"
qingyunke "github.com/FloatTech/ZeroBot-Plugin/plugin_qingyunke"
fileutil "github.com/FloatTech/ZeroBot-Plugin/utils/file"
aireply "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_reply"
"github.com/FloatTech/ZeroBot-Plugin/utils/file"
"github.com/FloatTech/ZeroBot-Plugin/utils/web"
)
@@ -47,19 +47,17 @@ func init() {
engine.OnMessage(zero.OnlyToMe, getAcquire).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
msg := ctx.ExtractPlainText()
// 调用青云客接口
reply, err := qingyunke.GetMessage(msg)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
AIReply := aireply.NewAIReply(aireply.GetReplyMode(ctx))
// 把消息里的椛椛替换成对应接口机器人的名字
msg = AIReply.DealQuestion(msg)
reply := AIReply.GetReply(msg)
// 挑出 face 表情
textReply, _ := qingyunke.DealReply(reply)
textReply, _ := AIReply.DealReply(reply)
// 拟声器生成音频
syntPath := getSyntPath()
fileName := getWav(textReply, syntPath, vocoderList[1], ctx.Event.UserID)
// 回复
ctx.SendChain(message.Record("file:///" + fileutil.BOTPATH + "/" + cachePath + fileName))
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + cachePath + fileName))
})
}
@@ -128,7 +126,7 @@ func getWav(text, syntPath, vocoder string, uid int64) (fileName string) {
}
defer res.Body.Close()
data, _ := ioutil.ReadAll(res.Body)
err = ioutil.WriteFile(cachePath+fileName, data, 0666)
err = os.WriteFile(cachePath+fileName, data, 0666)
if err != nil {
log.Errorln("[mockingbird]:", err)
}

View File

@@ -8,7 +8,7 @@ import (
reg "github.com/fumiama/go-registry"
)
var sr = reg.NewRegedit("reilia.eastasia.azurecontainer.io:32664", "fumiama", "--")
var sr = reg.NewRegedit("reilia.fumiama.top:32664", "fumiama", "--")
func TestGetHoliday(t *testing.T) {
registry.Connect()
@@ -24,7 +24,7 @@ func TestSetHoliday(t *testing.T) {
t.Fatal(err)
}
err = SetHoliday("元旦", 1, 2022, 1, 1)
err = SetHoliday("元旦", 1, 2023, 1, 1)
if err != nil {
t.Fatal(err)
}

View File

@@ -22,7 +22,7 @@ func NewHoliday(name string, dur, year int, month time.Month, day int) *Holiday
}
var (
registry = reg.NewRegReader("reilia.eastasia.azurecontainer.io:32664", "fumiama")
registry = reg.NewRegReader("reilia.fumiama.top:32664", "fumiama")
holidaymap map[string]*Holiday
)

View File

@@ -1,157 +0,0 @@
// Package qingyunke 基于青云客接口的聊天对话功能
package qingyunke
import (
"encoding/json"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"net/url"
"regexp"
"strconv"
"strings"
"time"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
)
var (
prio = 256
bucket = rate.NewManager(time.Minute, 20) // 青云客接口回复
engine *zero.Engine
)
func init() { // 插件主体
engine = control.Register("qingyunke", &control.Options{
DisableOnDefault: false,
Help: "青云客\n" +
"- @Bot 任意文本(任意一句话回复)",
})
// 回复 @和包括名字
engine.OnMessage(zero.OnlyToMe).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
if !bucket.Load(ctx.Event.UserID).Acquire() {
// 频繁触发,不回复
return
}
msg := ctx.ExtractPlainText()
// 调用青云客接口
reply, err := GetMessage(msg)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
// 挑出 face 表情
textReply, faceReply := DealReply(reply)
// 回复
time.Sleep(time.Second * 1)
if ctx.Event.MessageType == "group" {
if faceReply != -1 {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(textReply), message.Face(faceReply))
} else {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(textReply))
}
}
if ctx.Event.MessageType == "private" {
if faceReply != -1 {
ctx.SendChain(message.Text(textReply), message.Face(faceReply))
} else {
ctx.SendChain(message.Text(textReply))
}
}
})
// TODO: 待优化
/*
zero.OnRegex("CQ:image,file=|CQ:face,id=", zero.OnlyToMe, switchQYK()).SetBlock(false).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
imageURL := getPicture()
time.Sleep(time.Second * 1)
if ctx.Event.MessageType == "group" {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image(imageURL))
}
if ctx.Event.MessageType == "private" {
ctx.SendChain(message.Image(imageURL))
}
})
*/
}
// 青云客数据
type dataQYK struct {
Result int `json:"result"`
Content string `json:"content"`
}
const (
qykURL = "http://api.qingyunke.com/api.php"
key = "free"
appid = "0"
)
// GetMessage 青云客取消息
func GetMessage(msg string) (string, error) {
u := fmt.Sprintf(qykURL+"?key=%s&appid=%s&msg=%s", key, appid, url.QueryEscape(msg))
client := &http.Client{}
req, err := http.NewRequest("GET", u, nil)
if err != nil {
return "", err
}
// 自定义Header
req.Header.Set("User-Agent", getAgent())
req.Header.Set("Connection", "keep-alive")
req.Header.Set("Host", "api.qingyunke.com")
resp, err := client.Do(req)
if err != nil {
return "", err
}
defer resp.Body.Close()
bytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
}
fmt.Println(string(bytes))
var dataQYK dataQYK
if err := json.Unmarshal(bytes, &dataQYK); err != nil {
return "", err
}
return dataQYK.Content, nil
}
// DealReply 处理青云客返回文本
func DealReply(reply string) (textReply string, faceReply int) {
reg := regexp.MustCompile(`\{face:(\d+)\}(.*)`)
faceReply = -1
if reg.MatchString(reply) {
faceReply, _ = strconv.Atoi(reg.FindStringSubmatch(reply)[1])
textReply = reg.FindStringSubmatch(reply)[2]
} else {
textReply = reply
}
textReply = strings.ReplaceAll(textReply, "菲菲", zero.BotConfig.NickName[0])
textReply = strings.ReplaceAll(textReply, "{br}", "\n")
return
}
func getAgent() string {
agent := [...]string{
"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0",
"Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; en) Presto/2.8.131 Version/11.11",
"Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)",
"Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; The World)",
"User-Agent,Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50",
"User-Agent, Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)",
"User-Agent,Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50",
}
r := rand.New(rand.NewSource(time.Now().UnixNano()))
len1 := len(agent)
return agent[r.Intn(len1)]
}

30
plugin_score/data.go Normal file
View File

@@ -0,0 +1,30 @@
package score
import (
"os"
log "github.com/sirupsen/logrus"
"github.com/FloatTech/ZeroBot-Plugin/utils/process"
)
const (
cachePath = dbpath + "cache/"
dbpath = "data/score/"
dbfile = dbpath + "score.db"
)
// SDB 得分数据库
var SDB *DB
// 加载数据库
func init() {
go func() {
process.SleepAbout1sTo2s()
_ = os.MkdirAll(dbpath, 0755)
os.RemoveAll(cachePath)
_ = os.MkdirAll(cachePath, 0755)
SDB = Initialize(dbfile)
log.Println("[score]加载score数据库")
}()
}

125
plugin_score/model.go Normal file
View File

@@ -0,0 +1,125 @@
package score
import (
"os"
"time"
"github.com/jinzhu/gorm"
_ "github.com/logoove/sqlite" // import sql
)
// DB 分数数据库
type DB gorm.DB
// Score 分数结构体
type Score struct {
UID int64 `gorm:"column:uid;primary_key"`
Score int `gorm:"column:score;default:0"`
}
// TableName ...
func (Score) TableName() string {
return "score"
}
// SignIn 签到结构体
type SignIn struct {
UID int64 `gorm:"column:uid;primary_key"`
Count int `gorm:"column:count;default:0"`
UpdatedAt time.Time
}
// TableName ...
func (SignIn) TableName() string {
return "sign_in"
}
// Initialize 初始化ScoreDB数据库
func Initialize(dbpath string) *DB {
var err error
if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
// 生成文件
f, err := os.Create(dbpath)
if err != nil {
return nil
}
defer f.Close()
}
gdb, err := gorm.Open("sqlite3", dbpath)
if err != nil {
panic(err)
}
gdb.AutoMigrate(&Score{}).AutoMigrate(&SignIn{})
return (*DB)(gdb)
}
// Open ...
func Open(dbpath string) (*DB, error) {
db, err := gorm.Open("sqlite3", dbpath)
if err != nil {
return nil, err
}
return (*DB)(db), nil
}
// Close ...
func (sdb *DB) Close() error {
db := (*gorm.DB)(sdb)
return db.Close()
}
// GetScoreByUID 取得分数
func (sdb *DB) GetScoreByUID(uid int64) (s Score) {
db := (*gorm.DB)(sdb)
db.Debug().Model(&Score{}).FirstOrCreate(&s, "uid = ? ", uid)
return s
}
// InsertOrUpdateScoreByUID 插入或更新分数
func (sdb *DB) InsertOrUpdateScoreByUID(uid int64, score int) (err error) {
db := (*gorm.DB)(sdb)
s := Score{
UID: uid,
Score: score,
}
if err = db.Debug().Model(&Score{}).First(&s, "uid = ? ", uid).Error; err != nil {
// error handling...
if gorm.IsRecordNotFoundError(err) {
db.Debug().Model(&Score{}).Create(&s) // newUser not user
}
} else {
err = db.Debug().Model(&Score{}).Where("uid = ? ", uid).Update(
map[string]interface{}{
"score": score,
}).Error
}
return
}
// GetSignInByUID 取得签到次数
func (sdb *DB) GetSignInByUID(uid int64) (si SignIn) {
db := (*gorm.DB)(sdb)
db.Debug().Model(&SignIn{}).FirstOrCreate(&si, "uid = ? ", uid)
return si
}
// InsertOrUpdateSignInCountByUID 插入或更新签到次数
func (sdb *DB) InsertOrUpdateSignInCountByUID(uid int64, count int) (err error) {
db := (*gorm.DB)(sdb)
si := SignIn{
UID: uid,
Count: count,
}
if err = db.Debug().Model(&SignIn{}).First(&si, "uid = ? ", uid).Error; err != nil {
// error handling...
if gorm.IsRecordNotFoundError(err) {
db.Debug().Model(&SignIn{}).Create(&si) // newUser not user
}
} else {
err = db.Debug().Model(&SignIn{}).Where("uid = ? ", uid).Update(
map[string]interface{}{
"count": count,
}).Error
}
return
}

189
plugin_score/sign_in.go Normal file
View File

@@ -0,0 +1,189 @@
// Package score 签到,答题得分
package score
import (
"fmt"
"os"
"strconv"
"sync"
"time"
"github.com/fogleman/gg"
log "github.com/sirupsen/logrus"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
"github.com/FloatTech/ZeroBot-Plugin/control"
"github.com/FloatTech/ZeroBot-Plugin/utils/ctxext"
"github.com/FloatTech/ZeroBot-Plugin/utils/file"
"github.com/FloatTech/ZeroBot-Plugin/utils/txt2img"
"github.com/FloatTech/ZeroBot-Plugin/utils/web"
)
const (
prio = 5
backgroundURL = "https://iw233.cn/API/pc.php?type=json"
referer = "https://iw233.cn/main.html"
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
signinMax = 1
// ScoreMax 分数上限定为120
ScoreMax = 120
)
var (
engine = control.Register("score", &control.Options{
DisableOnDefault: false,
Help: "签到得分\n- 签到\n- 获得签到背景[@xxx]|获得签到背景",
})
levelArray = [...]int{0, 1, 2, 5, 10, 20, 35, 55, 75, 100, 120}
// 下载锁
mu sync.Mutex
)
func init() {
engine.OnFullMatch("签到").SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
uid := ctx.Event.UserID
now := time.Now()
today := now.Format("20060102")
si := SDB.GetSignInByUID(uid)
picFile := cachePath + strconv.FormatInt(uid, 10) + today + ".png"
if file.IsNotExist(picFile) {
mu.Lock()
initPic(picFile)
mu.Unlock()
}
siUpdateTimeStr := si.UpdatedAt.Format("20060102")
if siUpdateTimeStr != today {
if err := SDB.InsertOrUpdateSignInCountByUID(uid, 0); err != nil {
log.Errorln("[score]:", err)
}
}
if si.Count >= signinMax && siUpdateTimeStr == today {
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("今天你已经签到过了!"))
return
}
if err := SDB.InsertOrUpdateSignInCountByUID(uid, si.Count+1); err != nil {
log.Errorln("[score]:", err)
}
back, err := gg.LoadImage(picFile)
if err != nil {
log.Errorln("[score]:", err)
}
canvas := gg.NewContext(back.Bounds().Size().X, int(float64(back.Bounds().Size().Y)*1.7))
canvas.SetRGB(1, 1, 1)
canvas.Clear()
canvas.DrawImage(back, 0, 0)
monthWord := now.Format("01/02")
hourWord := getHourWord(now)
if err = canvas.LoadFontFace(txt2img.BoldFontFile, float64(back.Bounds().Size().X)*0.1); err != nil {
log.Println("[score]:", err)
}
canvas.SetRGB(0, 0, 0)
canvas.DrawString(hourWord, float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.2)
canvas.DrawString(monthWord, float64(back.Bounds().Size().X)*0.6, float64(back.Bounds().Size().Y)*1.2)
nickName := ctxext.CardOrNickName(ctx, uid)
if err = canvas.LoadFontFace(txt2img.FontFile, float64(back.Bounds().Size().X)*0.04); err != nil {
log.Println("[score]:", err)
}
add := 1
canvas.DrawString(nickName+fmt.Sprintf(" 小熊饼干+%d", add), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.3)
score := SDB.GetScoreByUID(uid).Score
score += add
if score > ScoreMax {
score = ScoreMax
ctx.SendChain(message.At(uid), message.Text("你获得的小熊饼干已经达到上限"))
}
if err := SDB.InsertOrUpdateScoreByUID(uid, score); err != nil {
log.Println("[score]:", err)
}
level := getLevel(score)
canvas.DrawString("当前小熊饼干:"+strconv.FormatInt(int64(score), 10), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.4)
canvas.DrawString("LEVEL:"+strconv.FormatInt(int64(level), 10), float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.5)
canvas.DrawRectangle(float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.55, float64(back.Bounds().Size().X)*0.6, float64(back.Bounds().Size().Y)*0.1)
canvas.SetRGB255(150, 150, 150)
canvas.Fill()
var nextLevelScore int
if level < 10 {
nextLevelScore = levelArray[level+1]
} else {
nextLevelScore = ScoreMax
}
canvas.SetRGB255(0, 0, 0)
canvas.DrawRectangle(float64(back.Bounds().Size().X)*0.1, float64(back.Bounds().Size().Y)*1.55, float64(back.Bounds().Size().X)*0.6*float64(score)/float64(nextLevelScore), float64(back.Bounds().Size().Y)*0.1)
canvas.SetRGB255(102, 102, 102)
canvas.Fill()
canvas.DrawString(fmt.Sprintf("%d/%d", score, nextLevelScore), float64(back.Bounds().Size().X)*0.75, float64(back.Bounds().Size().Y)*1.62)
canvasBase64, err := txt2img.CanvasToBase64(canvas)
if err != nil {
log.Println("[score]:", err)
}
ctx.SendChain(message.Image("base64://" + helper.BytesToString(canvasBase64)))
})
engine.OnPrefix("获得签到背景", zero.OnlyGroup).SetBlock(true).SetPriority(20).
Handle(func(ctx *zero.Ctx) {
param := ctx.State["args"].(string)
var uidStr string
if len(ctx.Event.Message) > 1 && ctx.Event.Message[1].Type == "at" {
uidStr = ctx.Event.Message[1].Data["qq"]
} else if param == "" {
uidStr = strconv.FormatInt(ctx.Event.UserID, 10)
}
picFile := cachePath + uidStr + time.Now().Format("20060102") + ".png"
if file.IsNotExist(picFile) {
mu.Lock()
initPic(picFile)
mu.Unlock()
}
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + picFile))
})
}
func getHourWord(t time.Time) string {
switch {
case 6 <= t.Hour() && t.Hour() < 12:
return "早上好"
case 12 <= t.Hour() && t.Hour() < 14:
return "中午好"
case 14 <= t.Hour() && t.Hour() < 19:
return "下午好"
case 19 <= t.Hour() && t.Hour() < 24:
return "晚上好"
case 0 <= t.Hour() && t.Hour() < 6:
return "凌晨好"
default:
return ""
}
}
func getLevel(count int) int {
for k, v := range levelArray {
if count == v {
return k
} else if count < v {
return k - 1
}
}
return -1
}
func initPic(picFile string) {
if file.IsNotExist(picFile) {
data, err := web.ReqWith(backgroundURL, "GET", referer, ua)
if err != nil {
log.Errorln("[score]:", err)
}
picURL := gjson.Get(string(data), "pic").String()
data, err = web.ReqWith(picURL, "GET", "", ua)
if err != nil {
log.Errorln("[score]:", err)
}
err = os.WriteFile(picFile, data, 0666)
if err != nil {
log.Errorln("[score]:", err)
}
}
}

View File

@@ -28,7 +28,7 @@ const (
)
var (
engine = control.Register("curse", &control.Options{
engine = control.Register("shadiao", &control.Options{
DisableOnDefault: false,
Help: "沙雕app\n" +
"- 骂他[@xxx]|骂他[qq号](停用)\n- 骂我(停用)\n- 哄我\n- 渣我\n- 来碗绿茶\n- 发个朋友圈\n- 来碗毒鸡汤\n- 讲个段子",

View File

@@ -115,11 +115,10 @@ func (vdb *VtbDB) GetAllSecondCategoryMessageByFirstIndex(firstIndex int) string
db := (*gorm.DB)(vdb)
secondStepMessage := "请选择一个语录类别并发送序号:\n"
var scl []SecondCategory
var count int
var fc FirstCategory
db.Model(FirstCategory{}).Where("first_category_index = ?", firstIndex).First(&fc)
err := db.Debug().Model(&SecondCategory{}).Find(&scl, "first_category_uid = ?", fc.FirstCategoryUID).Count(&count).Error
if err != nil || count == 0 {
err := db.Debug().Model(&SecondCategory{}).Find(&scl, "first_category_uid = ?", fc.FirstCategoryUID).Error
if err != nil || len(scl) == 0 {
log.Errorln("[vtb/model]数据库读取错误", err)
return ""
}
@@ -135,10 +134,9 @@ func (vdb *VtbDB) GetAllThirdCategoryMessageByFirstIndexAndSecondIndex(firstInde
thirdStepMessage := "请选择一个语录并发送序号:\n"
var fc FirstCategory
db.Model(FirstCategory{}).Where("first_category_index = ?", firstIndex).First(&fc)
var count int
var tcl []ThirdCategory
err := db.Debug().Model(&ThirdCategory{}).Find(&tcl, "first_category_uid = ? and second_category_index = ?", fc.FirstCategoryUID, secondIndex).Count(&count).Error
if err != nil || count == 0 {
err := db.Debug().Model(&ThirdCategory{}).Find(&tcl, "first_category_uid = ? and second_category_index = ?", fc.FirstCategoryUID, secondIndex).Error
if err != nil || len(tcl) == 0 {
log.Errorln("[vtb/model]数据库读取错误", err)
return ""
}
@@ -172,7 +170,7 @@ func (vdb *VtbDB) RandomVtb() ThirdCategory {
func (vdb *VtbDB) GetFirstCategoryByFirstUID(firstUID string) FirstCategory {
db := (*gorm.DB)(vdb)
var fc FirstCategory
db.Model(FirstCategory{}).Where("first_category_uid = ?", firstUID).Take(&fc)
db.Model(FirstCategory{}).Take(&fc, "first_category_uid = ?", firstUID)
return fc
}
@@ -227,7 +225,7 @@ func (vdb *VtbDB) GetVtbList() (uidList []string) {
}
log.Println(fc)
if err := db.Debug().Model(&FirstCategory{}).Where("first_category_uid = ?", fc.FirstCategoryUID).First(&fc).Error; err != nil {
if err := db.Debug().Model(&FirstCategory{}).First(&fc, "first_category_uid = ?", fc.FirstCategoryUID).Error; err != nil {
if gorm.IsRecordNotFoundError(err) {
db.Debug().Model(&FirstCategory{}).Create(&fc) // newUser not user
}
@@ -290,7 +288,7 @@ func (vdb *VtbDB) StoreVtb(uid string) {
FirstCategoryUID: uid,
}
if err := db.Debug().Model(&SecondCategory{}).Where("first_category_uid = ? and second_category_index = ?", uid, secondIndex).First(&sc).Error; err != nil {
if err := db.Debug().Model(&SecondCategory{}).First(&sc, "first_category_uid = ? and second_category_index = ?", uid, secondIndex).Error; err != nil {
// error handling...
if gorm.IsRecordNotFoundError(err) {
db.Debug().Model(&SecondCategory{}).Create(&sc) // newUser not user
@@ -319,8 +317,8 @@ func (vdb *VtbDB) StoreVtb(uid string) {
}
log.Println(tc)
if err := db.Debug().Model(&ThirdCategory{}).Where("first_category_uid = ? and second_category_index = ? and third_category_index = ?",
uid, secondIndex, thirdIndex).First(&tc).Error; err != nil {
if err := db.Debug().Model(&ThirdCategory{}).First(&tc, "first_category_uid = ? and second_category_index = ? and third_category_index = ?",
uid, secondIndex, thirdIndex).Error; err != nil {
if gorm.IsRecordNotFoundError(err) {
db.Debug().Model(&ThirdCategory{}).Create(&tc) // newUser not user
}

View File

@@ -22,7 +22,7 @@ const (
)
var (
registry = reg.NewRegReader("reilia.eastasia.azurecontainer.io:32664", "fumiama")
registry = reg.NewRegReader("reilia.fumiama.top:32664", "fumiama")
connmu, getmu sync.Mutex
processes sync.WaitGroup
connerr error

View File

@@ -17,10 +17,31 @@ func Min(a, b int) int {
return a
}
// intSize is either 32 or 64.
const intSize = 32 << (^uint(0) >> 63)
// Abs 返回绝对值,该函数将被内联
func Abs(x int) int {
if x < 0 {
return -x
}
return x
// m := -1 if x < 0. m := 0 otherwise.
m := x >> (intSize - 1)
// In two's complement representation, the negative number
// of any number (except the smallest one) can be computed
// by flipping all the bits and add 1. This is faster than
// code with a branch.
// See Hacker's Delight, section 2-4.
return (x ^ m) - m
}
// Abs64 返回绝对值,该函数将被内联
func Abs64(x int64) int64 {
// m := -1 if x < 0. m := 0 otherwise.
m := x >> (64 - 1)
// In two's complement representation, the negative number
// of any number (except the smallest one) can be computed
// by flipping all the bits and add 1. This is faster than
// code with a branch.
// See Hacker's Delight, section 2-4.
return (x ^ m) - m
}

View File

@@ -18,16 +18,21 @@ import (
const (
whitespace = "\t\n\r\x0b\x0c"
fontpath = "data/Font/"
fontfile = fontpath + "regular.ttf"
// FontPath 通用字体路径
FontPath = "data/Font/"
// FontFile 苹方字体
FontFile = FontPath + "regular.ttf"
// BoldFontFile 粗体苹方字体
BoldFontFile = FontPath + "regular-bold.ttf"
)
// 加载数据库
func init() {
go func() {
process.SleepAbout1sTo2s()
_ = os.MkdirAll(fontpath, 0755)
_, _ = file.GetLazyData(fontfile, false, true)
_ = os.MkdirAll(FontPath, 0755)
_, _ = file.GetLazyData(FontFile, false, true)
_, _ = file.GetLazyData(BoldFontFile, false, true)
}()
}
@@ -35,19 +40,14 @@ func init() {
func RenderToBase64(text string, width, fontSize int) (base64Bytes []byte, err error) {
canvas, err := Render(text, width, fontSize)
if err != nil {
log.Println("err:", err)
log.Println("[txt2img]:", err)
return nil, err
}
// 转成 base64
buffer := new(bytes.Buffer)
encoder := base64.NewEncoder(base64.StdEncoding, buffer)
var opt jpeg.Options
opt.Quality = 70
if err = jpeg.Encode(encoder, canvas.Image(), &opt); err != nil {
base64Bytes, err = CanvasToBase64(canvas)
if err != nil {
log.Println("[txt2img]:", err)
return nil, err
}
encoder.Close()
base64Bytes = buffer.Bytes()
return
}
@@ -74,12 +74,12 @@ func Render(text string, width, fontSize int) (canvas *gg.Context, err error) {
}
}
canvas = gg.NewContext((fontSize+3)*width/2, (len(buff)+2)*fontSize)
canvas = gg.NewContext((fontSize+4)*width/2, (len(buff)+2)*fontSize)
canvas.SetRGB(1, 1, 1)
canvas.Clear()
canvas.SetRGB(0, 0, 0)
if err = canvas.LoadFontFace(fontfile, float64(fontSize)); err != nil {
log.Println("err:", err)
if err = canvas.LoadFontFace(FontFile, float64(fontSize)); err != nil {
log.Println("[txt2img]:", err)
return nil, err
}
for i, v := range buff {
@@ -89,3 +89,17 @@ func Render(text string, width, fontSize int) (canvas *gg.Context, err error) {
}
return
}
// CanvasToBase64 gg内容转为base64
func CanvasToBase64(canvas *gg.Context) (base64Bytes []byte, err error) {
buffer := new(bytes.Buffer)
encoder := base64.NewEncoder(base64.StdEncoding, buffer)
var opt jpeg.Options
opt.Quality = 70
if err = jpeg.Encode(encoder, canvas.Image(), &opt); err != nil {
return nil, err
}
encoder.Close()
base64Bytes = buffer.Bytes()
return
}

21
utils/web/ipv6.go Normal file
View File

@@ -0,0 +1,21 @@
package web
import (
"io"
"net/http"
"github.com/sirupsen/logrus"
)
// IsSupportIPv6 检查本机是否支持 ipv6
var IsSupportIPv6 = func() bool {
resp, err := http.Get("http://v6.ipv6-test.com/json/widgetdata.php?callback=?")
if err != nil {
logrus.Infoln("[web] 本机不支持ipv6")
return false
}
_, _ = io.ReadAll(resp.Body)
_ = resp.Body.Close()
logrus.Infoln("[web] 本机支持ipv6")
return true
}()