mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-12 10:10:25 +00:00
✨ 新增 本地 setu 插件
This commit is contained in:
16
utils/rule/extension.go
Normal file
16
utils/rule/extension.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package rule
|
||||
|
||||
import zero "github.com/wdvxdr1123/ZeroBot"
|
||||
|
||||
// FirstValueInList 判断正则匹配的第一个参数是否在列表中
|
||||
func FirstValueInList(list []string) zero.Rule {
|
||||
return func(ctx *zero.Ctx) bool {
|
||||
first := ctx.State["regex_matched"].([]string)[1]
|
||||
for i := range list {
|
||||
if first == list[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -143,6 +143,11 @@ func (db *Sqlite) Find(table string, objptr interface{}, condition string) error
|
||||
return err
|
||||
}
|
||||
|
||||
// Pick 从 table 随机一行
|
||||
func (db *Sqlite) Pick(table string, objptr interface{}) error {
|
||||
return db.Find(table, objptr, "ORDER BY RANDOM() limit 1")
|
||||
}
|
||||
|
||||
// ListTables 列出所有表名
|
||||
// 返回所有表名+错误
|
||||
func (db *Sqlite) ListTables() (s []string, err error) {
|
||||
|
||||
Reference in New Issue
Block a user