Merge pull request #46 from fumiama/master

升级ACGImage,隐藏一些包暴露的函数
This commit is contained in:
Kanri 2021-08-02 23:57:09 -05:00 committed by GitHub
commit e9ace4f3ed
5 changed files with 23 additions and 19 deletions

3
go.mod
View File

@ -4,8 +4,9 @@ go 1.16
require ( require (
github.com/FloatTech/AnimeAPI v0.0.0-20210713044920-63367fe18ccd github.com/FloatTech/AnimeAPI v0.0.0-20210713044920-63367fe18ccd
github.com/FloatTech/ZeroBot-ACGImage v1.4.3 github.com/FloatTech/ZeroBot-ACGImage v1.5.1
github.com/FloatTech/ZeroBot-Plugin-Timer v1.3.4 github.com/FloatTech/ZeroBot-Plugin-Timer v1.3.4
github.com/FloatTech/Zerobot-ACGImage-Classify v1.2.1
github.com/StackExchange/wmi v1.2.1 // indirect github.com/StackExchange/wmi v1.2.1 // indirect
github.com/go-ole/go-ole v1.2.5 // indirect github.com/go-ole/go-ole v1.2.5 // indirect
github.com/robfig/cron v1.2.0 github.com/robfig/cron v1.2.0

4
go.sum
View File

@ -16,6 +16,8 @@ github.com/FloatTech/ZeroBot-ACGImage v1.4.2 h1:/jj/+5a4EeejeqIDkeUbaxpCpZfLPCOD
github.com/FloatTech/ZeroBot-ACGImage v1.4.2/go.mod h1:CtEYnFTjgzH4v1jaowyyjBmjSKK3p8WPXExfGnVmx1E= github.com/FloatTech/ZeroBot-ACGImage v1.4.2/go.mod h1:CtEYnFTjgzH4v1jaowyyjBmjSKK3p8WPXExfGnVmx1E=
github.com/FloatTech/ZeroBot-ACGImage v1.4.3 h1:lQTKfrVYdO5T+4KfC8U2bIxYnZql2hG2tSo/msTGRcI= github.com/FloatTech/ZeroBot-ACGImage v1.4.3 h1:lQTKfrVYdO5T+4KfC8U2bIxYnZql2hG2tSo/msTGRcI=
github.com/FloatTech/ZeroBot-ACGImage v1.4.3/go.mod h1:CtEYnFTjgzH4v1jaowyyjBmjSKK3p8WPXExfGnVmx1E= github.com/FloatTech/ZeroBot-ACGImage v1.4.3/go.mod h1:CtEYnFTjgzH4v1jaowyyjBmjSKK3p8WPXExfGnVmx1E=
github.com/FloatTech/ZeroBot-ACGImage v1.5.1 h1:iolon1PR4AjEJJmUHEDfCXL8tBZOx5W21hRvNirX1Bw=
github.com/FloatTech/ZeroBot-ACGImage v1.5.1/go.mod h1:Q9k43tGy2c5sDxw3XZc2An4YfqkN1wWIXeXUH2GlaBg=
github.com/FloatTech/ZeroBot-Plugin-Timer v1.2.4 h1:BMrSHJO1lWKTKU1DCK+XEpTaK38FMlBEIywFLIiatu8= github.com/FloatTech/ZeroBot-Plugin-Timer v1.2.4 h1:BMrSHJO1lWKTKU1DCK+XEpTaK38FMlBEIywFLIiatu8=
github.com/FloatTech/ZeroBot-Plugin-Timer v1.2.4/go.mod h1:femu/wVuqVSN/rg209qksMx8/2OKUF8l1PZCNg4RwVA= github.com/FloatTech/ZeroBot-Plugin-Timer v1.2.4/go.mod h1:femu/wVuqVSN/rg209qksMx8/2OKUF8l1PZCNg4RwVA=
github.com/FloatTech/ZeroBot-Plugin-Timer v1.3.1 h1:AT/nudxY5murKpEyP+ZZTczknSipeZPP2tId6/2I7Nw= github.com/FloatTech/ZeroBot-Plugin-Timer v1.3.1 h1:AT/nudxY5murKpEyP+ZZTczknSipeZPP2tId6/2I7Nw=
@ -26,6 +28,8 @@ github.com/FloatTech/ZeroBot-Plugin-Timer v1.3.3 h1:NXk18XCfy4cCSMXru/NHfCdf26o3
github.com/FloatTech/ZeroBot-Plugin-Timer v1.3.3/go.mod h1:NuODdnVhf9AClsJBdYFqnL9sQE7VIRZyZos37J286n0= github.com/FloatTech/ZeroBot-Plugin-Timer v1.3.3/go.mod h1:NuODdnVhf9AClsJBdYFqnL9sQE7VIRZyZos37J286n0=
github.com/FloatTech/ZeroBot-Plugin-Timer v1.3.4 h1:nRJqY/S7TRlN32MQGIBH3UWfVrpjxpJXCnp42pd2O2Q= github.com/FloatTech/ZeroBot-Plugin-Timer v1.3.4 h1:nRJqY/S7TRlN32MQGIBH3UWfVrpjxpJXCnp42pd2O2Q=
github.com/FloatTech/ZeroBot-Plugin-Timer v1.3.4/go.mod h1:NuODdnVhf9AClsJBdYFqnL9sQE7VIRZyZos37J286n0= github.com/FloatTech/ZeroBot-Plugin-Timer v1.3.4/go.mod h1:NuODdnVhf9AClsJBdYFqnL9sQE7VIRZyZos37J286n0=
github.com/FloatTech/Zerobot-ACGImage-Classify v1.2.1 h1:HEdT6yq06lV94jcArutpyqQLaPpczs0bTd6gdwVG1ps=
github.com/FloatTech/Zerobot-ACGImage-Classify v1.2.1/go.mod h1:swPvVKyXu1YFWZ7Kt6R79LgIa16hs4cE1E5LroBB2SQ=
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 h1:5sXbqlSomvdjlRbWyNqkPsJ3Fg+tQZCbgeX1VGljbQY= github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 h1:5sXbqlSomvdjlRbWyNqkPsJ3Fg+tQZCbgeX1VGljbQY=
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/StackExchange/wmi v1.2.0 h1:noJEYkMQVlFCEAc+2ma5YyRhlfjcWfZqk5sBRYozdyM= github.com/StackExchange/wmi v1.2.0 h1:noJEYkMQVlFCEAc+2ma5YyRhlfjcWfZqk5sBRYozdyM=

View File

@ -26,13 +26,6 @@ func init() {
zero.OnFullMatch("来份萝莉"). zero.OnFullMatch("来份萝莉").
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
go func() { go func() {
min := func(a, b int) int {
if a < b {
return a
} else {
return b
}
}
for i := 0; i < min(cap(QUEUE)-len(QUEUE), 2); i++ { for i := 0; i < min(cap(QUEUE)-len(QUEUE), 2); i++ {
resp, err := http.Get(API) resp, err := http.Get(API)
if err != nil { if err != nil {
@ -63,3 +56,11 @@ func init() {
} }
}) })
} }
func min(a, b int) int {
if a < b {
return a
} else {
return b
}
}

View File

@ -56,7 +56,7 @@ var (
) )
func init() { // 插件主体 func init() { // 插件主体
zero.OnRegex(`^来份(.*)$`, FirstValueInList(POOL.List)).SetBlock(true).SetPriority(20). zero.OnRegex(`^来份(.*)$`, firstValueInList(POOL.List)).SetBlock(true).SetPriority(20).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.UserID).Acquire() { if !limit.Load(ctx.Event.UserID).Acquire() {
ctx.SendChain(message.Text("请稍后重试0x0...")) ctx.SendChain(message.Text("请稍后重试0x0..."))
@ -65,7 +65,7 @@ func init() { // 插件主体
var type_ = ctx.State["regex_matched"].([]string)[1] var type_ = ctx.State["regex_matched"].([]string)[1]
// 补充池子 // 补充池子
go func() { go func() {
times := Min(POOL.Max-POOL.Size(type_), 2) times := min(POOL.Max-POOL.Size(type_), 2)
for i := 0; i < times; i++ { for i := 0; i < times; i++ {
illust := &pixiv.Illust{} illust := &pixiv.Illust{}
// 查询出一张图片 // 查询出一张图片
@ -101,7 +101,7 @@ func init() { // 插件主体
return return
}) })
zero.OnRegex(`^添加(.*?)(\d+)$`, FirstValueInList(POOL.List), zero.SuperUserPermission).SetBlock(true).SetPriority(21). zero.OnRegex(`^添加(.*?)(\d+)$`, firstValueInList(POOL.List), zero.SuperUserPermission).SetBlock(true).SetPriority(21).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
var ( var (
type_ = ctx.State["regex_matched"].([]string)[1] type_ = ctx.State["regex_matched"].([]string)[1]
@ -133,7 +133,7 @@ func init() { // 插件主体
return return
}) })
zero.OnRegex(`^删除(.*?)(\d+)$`, FirstValueInList(POOL.List), zero.SuperUserPermission).SetBlock(true).SetPriority(22). zero.OnRegex(`^删除(.*?)(\d+)$`, firstValueInList(POOL.List), zero.SuperUserPermission).SetBlock(true).SetPriority(22).
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
var ( var (
type_ = ctx.State["regex_matched"].([]string)[1] type_ = ctx.State["regex_matched"].([]string)[1]
@ -167,8 +167,8 @@ func init() { // 插件主体
}) })
} }
// FirstValueInList 判断正则匹配的第一个参数是否在列表中 // firstValueInList 判断正则匹配的第一个参数是否在列表中
func FirstValueInList(list []string) zero.Rule { func firstValueInList(list []string) zero.Rule {
return func(ctx *zero.Ctx) bool { return func(ctx *zero.Ctx) bool {
first := ctx.State["regex_matched"].([]string)[1] first := ctx.State["regex_matched"].([]string)[1]
for i := range list { for i := range list {
@ -180,8 +180,8 @@ func FirstValueInList(list []string) zero.Rule {
} }
} }
// Min 返回两数最小值 // min 返回两数最小值
func Min(a, b int) int { func min(a, b int) int {
switch { switch {
default: default:
return a return a

View File

@ -2,7 +2,6 @@ package plugin_setutime
import ( import (
"database/sql" "database/sql"
"errors"
"reflect" "reflect"
"strings" "strings"
@ -133,9 +132,8 @@ func (db *Sqlite) Select(table string, objptr interface{}, condition string) (er
if err != nil { if err != nil {
return err return err
} }
return nil
} }
return errors.New("数据库无此条件项目") return nil
} }
// Delete 删除数据库 // Delete 删除数据库