Compare commits

...

32 Commits

Author SHA1 Message Date
fumiama
5aad22f254 ✏️ 更新README 2021-09-12 14:43:17 +08:00
fumiama
815c8f97d0 ✏️ 更新README 2021-09-12 14:41:25 +08:00
fumiama
7123fc7e37 ✏️ 更新README 2021-09-12 14:38:43 +08:00
github-actions[bot]
fee3d9c145 🎨 改进代码样式 2021-09-12 01:50:01 +00:00
Kanri
6808e6e1b4 更新依赖 2021-09-12 09:48:43 +08:00
Kanri
12f25a308a 增加制图插件 2021-09-12 09:48:29 +08:00
fumiama
7fe401faa8 ✏️ 缩小青云客匹配范围 2021-09-10 15:05:15 +08:00
fumiama
182fb7c783 ✏️ 缩小青云客匹配范围 2021-09-10 15:04:37 +08:00
fumiama
c06b53afef ✏️ 缩小青云客匹配范围 2021-09-10 15:00:05 +08:00
fumiama
65a5b53b88 ✏️ 缩小青云客匹配范围 2021-09-10 14:52:36 +08:00
fumiama
e8503e97e3 ✏️ 修复帮助冲突 2021-09-10 14:43:44 +08:00
fumiama
f9a914926e ✏️ 美化格式 2021-09-10 14:31:44 +08:00
fumiama
8d4d6c7e5e ✏️ 美化格式 2021-09-10 14:31:10 +08:00
fumiama
dbb681e8a6 ✏️ 插件控制 增加当前群开启状态显示 2021-09-10 14:29:03 +08:00
fumiama
f0d7b38a73 ✏️ 避免重复调用 2021-09-10 14:16:33 +08:00
fumiama
70da534bfb Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2021-09-10 14:00:56 +08:00
fumiama
308ec05405 ✏️ 修复首次启动可能 panic 2021-09-10 14:00:46 +08:00
Kanri
5fe5e8a304 Update README.md 2021-09-09 23:58:44 +08:00
fumiama
b02789b560 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2021-09-09 20:58:10 +08:00
fumiama
7e98064e09 ✏️ banner 更新版本与时间 2021-09-09 20:58:01 +08:00
github-actions[bot]
eaada5667e 🎨 改进代码样式 2021-09-09 12:51:27 +00:00
fumiama
b83ca94d98 ✏️ 优化排版 2021-09-09 20:50:48 +08:00
fumiama
bd88c68208 ✏️ 增加 setblock 避免冲突 2021-09-09 12:31:57 +08:00
fumiama
6e0b754a66 ✏️ 优化control 2021-09-09 12:21:48 +08:00
github-actions[bot]
94abf34466 🎨 改进代码样式 2021-09-09 03:14:09 +00:00
fumiama
91396c8885 应用插件控制到大部分插件 2021-09-09 11:13:23 +08:00
fumiama
cb3cfa054b ✏️ 取消部分 @ 以免多次匹配 2021-09-09 00:45:49 +08:00
fumiama
ebf58d4b73 Merge branch 'master' of https://github.com/FloatTech/ZeroBot-Plugin 2021-09-09 00:38:04 +08:00
fumiama
f704cddae8 修正 2021-09-09 00:37:49 +08:00
github-actions[bot]
f03d2f3940 🎨 改进代码样式 2021-09-08 16:20:47 +00:00
fumiama
087c6c0298 新增插件控制 2021-09-09 00:20:04 +08:00
fumiama
be49ba83b3 ✏️ 根据 PID 搜图增加删图判断 2021-09-08 18:40:41 +08:00
31 changed files with 587 additions and 237 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,5 @@
data/SetuTime/cache
data/control
data/SetuTime/search
data/manager
data/acgimage

View File

@@ -19,7 +19,11 @@
</div>
## 功能
- **插件控制**
- [x] /启用 xxx
- [x] /禁用 xxx
- [x] /用法 xxx
- [x] /服务列表
- **聊天** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_chat"`
- [x] [BOT名字]
- [x] [戳一戳BOT]
@@ -46,10 +50,10 @@
- [x] *入群欢迎
- [x] *退群通知
- [x] 设置欢迎语[欢迎~]
- [x] 在MMdd日的hhmm分时(用http://url)提醒大家xxx
- [x] 在MM月[每周|周几]的hhmm分时(用http://url)提醒大家xxx
- [x] 取消在MMdd日的hhmm分的提醒
- [x] 取消在MM月[每周|周几]的hhmm分的提醒
- [x][MM]月[dd]日的[hh]点[mm]分时(用[url])提醒大家[xxx]
- [x][MM]月[每周|周几]的[hh]点[mm]分时(用[url])提醒大家[xxx]
- [x] 取消在[MM]月[dd]日的[hh]点[mm]分的提醒
- [x] 取消在[MM]月[每周|周几]的[hh]点[mm]分的提醒
- [x] 列出所有提醒
- [x] 翻牌
- [x] [开启|关闭]入群验证
@@ -59,11 +63,10 @@
- [ ] 警告[@xxx]
- [x] run[xxx]
- **GitHub仓库搜索** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_github"`
- [x] > github [xxx]
- [x] > github -p [xxx]
- [x] >github [xxx]
- [x] >github -p [xxx]
- **在线代码运行** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_runcode"`
- [x] > runcode help
- [x] > runcode [on/off]
- [x] > runcode [language] help
- [x] > runcode [language] [code block]
- **点歌** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_music"`
- [x] 点歌[xxx]
@@ -81,7 +84,7 @@
- [x] 爬[@xxx]
- [x] 摸[@xxx]
- [x] 搓[@xxx]
- 注:`main.go`中并未import该插件。详情见项目 --> https://github.com/tdf1939/ZeroBot-Plugin-Gif
- 注:更多指令见项目 --> https://github.com/tdf1939/ZeroBot-Plugin-Gif
- **涩图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_setutime"`
- [x] 来份[涩图/二次元/风景/车万]
- [x] 添加[涩图/二次元/风景/车万][P站图片ID]
@@ -99,29 +102,33 @@
- [x] 太涩了(撤回最近发的图)
- [x] 评价图片(发送一张图片让bot评分)
- **浅草寺求签** `github.com/FloatTech/ZeroBot-Plugin/plugin_omikuji`
- 本插件要求`Go`版本大于等于`1.17`
- [x] @BOT 求签|运势|占卜
- [x] 求签|运势|占卜
- **bilibili** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili"`
- [x] > bili info [名字]
- [x] >vup info [名字|uid]
- [x] >user info [名字|uid]
- [x] /开启粉丝日报
- **嘉然** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_diana"`
- [x] @BOT 小作文
- [x] @BOT 发大病
- [x] @BOT 教你一篇小作文[作文]
- [x] 小作文
- [x] 发大病
- [x] 教你一篇小作文[作文]
- [x] [回复]查重
- **AIfalse** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_false"`
- [x] 查询计算机当前活跃度 [身体检查]
- [ ] 简易语音
- [ ] 爬图合成 [@xxx]
- **minecraft** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft"`
- [x] 具体指令看代码
- [x] /mcstart xxx
- [x] /mcstop xxx
- [x] /mclist servername
- 注:此功能实现依赖[MCSManager](https://github.com/Suwings/MCSManager)项目对服务器的管理apimc服务器如果没有在该管理平台部署此功能无效
- **炉石** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs"`
- [x] 搜卡[xxxx]
- [x] [卡组代码xxx]
- [x] [卡组代码xxx]
-更多搜卡指令参数https://hs.fbigame.com/misc/searchhelp
- **青云客** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_qingyunke"`
- [x] @Bot 任意文本(任意一句话回复)
- [x] 关闭自动回复
- [x] 启动自动回复
- **关键字搜图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_image_finder"`
- [x] 来张 [xxx]
- **TODO...**
## 使用方法
@@ -129,8 +136,6 @@
本项目符合 [OneBot](https://github.com/howmanybots/onebot) 标准,可基于以下项目与机器人框架/平台进行交互
| 项目地址 | 平台 | 核心作者 | 备注 |
| --- | --- | --- | --- |
| [Yiwen-Chan/OneBot-YaYa](https://github.com/Yiwen-Chan/OneBot-YaYa) | [先驱](https://www.xianqubot.com/) | kanri | |
| [richardchien/coolq-http-api](https://github.com/richardchien/coolq-http-api) | CKYU | richardchien | 可在 Mirai 平台使用 [mirai-native](https://github.com/iTXTech/mirai-native) 加载 |
| [Mrs4s/go-cqhttp](https://github.com/Mrs4s/go-cqhttp) | [MiraiGo](https://github.com/Mrs4s/MiraiGo) | Mrs4s | |
| [yyuueexxiinngg/cqhttp-mirai](https://github.com/yyuueexxiinngg/cqhttp-mirai) | [Mirai](https://github.com/mamoe/mirai) | yyuueexxiinngg | |
| [takayama-lily/onebot](https://github.com/takayama-lily/onebot) | [OICQ](https://github.com/takayama-lily/oicq) | takayama | |

11
control/register.go Normal file
View File

@@ -0,0 +1,11 @@
package control
import (
zero "github.com/wdvxdr1123/ZeroBot"
)
func Register(service string, o *Options) *zero.Engine {
engine := zero.New()
engine.UsePreHandler(new(service, o).Handler())
return engine
}

197
control/rule.go Normal file
View File

@@ -0,0 +1,197 @@
// Package control 控制插件的启用与优先级等
package control
import (
"os"
"strconv"
"sync"
"github.com/sirupsen/logrus"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension"
"github.com/wdvxdr1123/ZeroBot/message"
. "github.com/FloatTech/ZeroBot-Plugin/data"
)
var (
db = &Sqlite{DBPath: "data/control/plugins.db"}
// managers 每个插件对应的管理
managers = map[string]*Control{}
mu = sync.RWMutex{}
hasinit bool
)
// Control is to control the plugins.
type Control struct {
sync.RWMutex
service string
options Options
}
// new returns Manager with settings.
func new(service string, o *Options) *Control {
m := &Control{service: service,
options: func() Options {
if o == nil {
return Options{}
}
return *o
}(),
}
mu.Lock()
defer mu.Unlock()
managers[service] = m
err := db.Create(service, &grpcfg{})
if err != nil {
panic(err)
}
return m
}
// enable enables a group to pass the Manager.
func (m *Control) enable(groupID int64) {
m.Lock()
err := db.Insert(m.service, &grpcfg{groupID, 0})
if err != nil {
logrus.Errorf("[control] %v", err)
}
m.Unlock()
}
// disable disables a group to pass the Manager.
func (m *Control) disable(groupID int64) {
m.Lock()
err := db.Insert(m.service, &grpcfg{groupID, 1})
if err != nil {
logrus.Errorf("[control] %v", err)
}
m.Unlock()
}
func (m *Control) isEnabledIn(gid int64) bool {
m.RLock()
var c grpcfg
err := db.Find(m.service, &c, "WHERE gid = "+strconv.FormatInt(gid, 10))
if err == nil {
m.RUnlock()
logrus.Debugf("[control] plugin %s of grp %d : %d", m.service, c.GroupID, c.Disable)
return c.Disable == 0
} else {
logrus.Errorf("[control] %v", err)
}
m.RUnlock()
if m.options.DisableOnDefault {
m.disable(gid)
} else {
m.enable(gid)
}
return !m.options.DisableOnDefault
}
// Handler 返回 预处理器
func (m *Control) Handler() zero.Rule {
return func(ctx *zero.Ctx) bool {
ctx.State["manager"] = m
return m.isEnabledIn(ctx.Event.GroupID)
}
}
// lookup returns a Manager by the service name, if
// not exist, it will returns nil.
func lookup(service string) (*Control, bool) {
mu.RLock()
defer mu.RUnlock()
m, ok := managers[service]
return m, ok
}
// forEach iterates through managers.
func forEach(iterator func(key string, manager *Control) bool) {
mu.RLock()
m := copyMap(managers)
mu.RUnlock()
for k, v := range m {
if !iterator(k, v) {
return
}
}
}
func copyMap(m map[string]*Control) map[string]*Control {
ret := make(map[string]*Control, len(m))
for k, v := range m {
ret[k] = v
}
return ret
}
func init() {
if !hasinit {
mu.Lock()
if !hasinit {
err := os.MkdirAll("data/control", 0755)
if err != nil {
panic(err)
} else {
hasinit = true
zero.OnCommandGroup([]string{"启用", "enable"}, zero.AdminPermission, zero.OnlyGroup).
Handle(func(ctx *zero.Ctx) {
model := extension.CommandModel{}
_ = ctx.Parse(&model)
service, ok := lookup(model.Args)
if !ok {
ctx.Send("没有找到指定服务!")
}
service.enable(ctx.Event.GroupID)
ctx.Send(message.Text("已启用服务: " + model.Args))
})
zero.OnCommandGroup([]string{"禁用", "disable"}, zero.AdminPermission, zero.OnlyGroup).
Handle(func(ctx *zero.Ctx) {
model := extension.CommandModel{}
_ = ctx.Parse(&model)
service, ok := lookup(model.Args)
if !ok {
ctx.Send("没有找到指定服务!")
}
service.disable(ctx.Event.GroupID)
ctx.Send(message.Text("已关闭服务: " + model.Args))
})
zero.OnCommandGroup([]string{"用法", "usage"}, zero.AdminPermission, zero.OnlyGroup).
Handle(func(ctx *zero.Ctx) {
model := extension.CommandModel{}
_ = ctx.Parse(&model)
service, ok := lookup(model.Args)
if !ok {
ctx.Send("没有找到指定服务!")
}
if service.options.Help != "" {
ctx.Send(service.options.Help)
} else {
ctx.Send("该服务无帮助!")
}
})
zero.OnCommandGroup([]string{"服务列表", "service_list"}, zero.AdminPermission, zero.OnlyGroup).
Handle(func(ctx *zero.Ctx) {
msg := `---服务列表---`
i := 0
forEach(func(key string, manager *Control) bool {
i++
msg += "\n" + strconv.Itoa(i) + `: `
if manager.isEnabledIn(ctx.Event.GroupID) {
msg += "●" + key
} else {
msg += "○" + key
}
return true
})
ctx.Send(message.Text(msg))
})
}
}
mu.Unlock()
}
}

13
control/tables.go Normal file
View File

@@ -0,0 +1,13 @@
package control
// grpcfg holds the group config for the Manager.
type grpcfg struct {
GroupID int64 `db:"gid"` // GroupID 群号
Disable int64 `db:"disable"` // Disable 默认启用该插件
}
// Options holds the optional parameters for the Manager.
type Options struct {
DisableOnDefault bool
Help string // 帮助文本信息
}

View File

@@ -1,4 +1,4 @@
package setutime
package data
import (
"database/sql"
@@ -8,16 +8,16 @@ import (
_ "modernc.org/sqlite" // 引入sqlite
)
// sqlite 数据库对象
type sqlite struct {
// Sqlite 数据库对象
type Sqlite struct {
DB *sql.DB
DBPath string
}
// create 生成数据库
// Create 生成数据库
// 默认结构体的第一个元素为主键
// 返回错误
func (db *sqlite) create(table string, objptr interface{}) (err error) {
func (db *Sqlite) Create(table string, objptr interface{}) (err error) {
if db.DB == nil {
database, err := sql.Open("sqlite", db.DBPath)
if err != nil {
@@ -53,10 +53,10 @@ func (db *sqlite) create(table string, objptr interface{}) (err error) {
return nil
}
// insert 插入数据集
// Insert 插入数据集
// 默认结构体的第一个元素为主键
// 返回错误
func (db *sqlite) insert(table string, objptr interface{}) (err error) {
func (db *Sqlite) Insert(table string, objptr interface{}) (err error) {
rows, err := db.DB.Query("SELECT * FROM " + table)
if err != nil {
return err
@@ -71,7 +71,7 @@ func (db *sqlite) insert(table string, objptr interface{}) (err error) {
top = len(tags) - 1
cmd = []string{}
)
cmd = append(cmd, "INSERT INTO")
cmd = append(cmd, "REPLACE INTO")
cmd = append(cmd, table)
for i := range tags {
switch i {
@@ -112,11 +112,11 @@ func (db *sqlite) insert(table string, objptr interface{}) (err error) {
return nil
}
// find 查询数据库
// Find 查询数据库
// condition 可为"WHERE id = 0"
// 默认字段与结构体元素顺序一致
// 返回错误
func (db *sqlite) find(table string, objptr interface{}, condition string) (err error) {
func (db *Sqlite) Find(table string, objptr interface{}, condition string) (err error) {
var cmd = []string{}
cmd = append(cmd, "SELECT * FROM ")
cmd = append(cmd, table)
@@ -142,10 +142,35 @@ func (db *sqlite) find(table string, objptr interface{}, condition string) (err
return nil
}
// del 删除数据库
// ListTables 列出所有表名
// 返回所有表名+错误
func (db *Sqlite) ListTables() (s []string, err error) {
rows, err := db.DB.Query("SELECT name FROM sqlite_master where type='table' order by name;")
if err != nil {
return
}
if rows.Err() != nil {
return nil, rows.Err()
}
defer rows.Close()
for rows.Next() {
if err != nil {
return
}
objptr := new(string)
err = rows.Scan(objptr)
if err == nil {
s = append(s, *objptr)
}
}
return
}
// Del 删除数据库
// condition 可为"WHERE id = 0"
// 返回错误
func (db *sqlite) del(table string, condition string) (err error) {
func (db *Sqlite) Del(table string, condition string) (err error) {
var cmd = []string{}
cmd = append(cmd, "DELETE FROM")
cmd = append(cmd, table)
@@ -161,9 +186,9 @@ func (db *sqlite) del(table string, condition string) (err error) {
return nil
}
// count 查询数据库行数
// Count 查询数据库行数
// 返回行数以及错误
func (db *sqlite) count(table string) (num int, err error) {
func (db *Sqlite) Count(table string) (num int, err error) {
var cmd = []string{}
cmd = append(cmd, "SELECT * FROM")
cmd = append(cmd, table)

1
go.mod
View File

@@ -12,6 +12,7 @@ require (
github.com/shirou/gopsutil v3.21.8+incompatible
github.com/sirupsen/logrus v1.8.1
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
github.com/tdf1939/ZeroBot-Plugin-Gif v0.0.0-20210828060956-389b1dc33652
github.com/tidwall/gjson v1.9.0
github.com/tklauser/go-sysconf v0.3.9 // indirect
github.com/wdvxdr1123/ZeroBot v1.2.3

40
go.sum
View File

@@ -11,11 +11,19 @@ github.com/antchfx/xpath v1.1.6/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNY
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4 h1:BBade+JlV/f7JstZ4pitd4tHhpN+w+6I+LyOS7B4fyU=
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4/go.mod h1:H7chHJglrhPPzetLdzBleF8d22WYOv7UM/lEKYiwlKM=
github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
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/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/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -55,8 +63,6 @@ github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6O
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
github.com/shirou/gopsutil v3.21.7+incompatible h1:g/wcPHcuCQvHSePVofjQljd2vX4ty0+J6VoMB+NPcdk=
github.com/shirou/gopsutil v3.21.7+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
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/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
@@ -71,9 +77,11 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1:J6v8awz+me+xeb/cUTotKgceAYouhIB3pjzgRd6IlGk=
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA=
github.com/tdf1939/ZeroBot-Plugin-Gif v0.0.0-20210828060956-389b1dc33652 h1:ZMZGgo6hboOetoExFZBecloH1zmQYJlWQWuhCeR0FiY=
github.com/tdf1939/ZeroBot-Plugin-Gif v0.0.0-20210828060956-389b1dc33652/go.mod h1:bkxKi7un9gCDvUUZAiIJF6k90pyj8rmxiXLJkiHcsMY=
github.com/tdf1939/img v0.0.0-20210827153520-90cb4e9580a3 h1:DUQxv4Ua1sb0/zOkExNJ/MSJcSnbZ7WT9thXCPWTh5U=
github.com/tdf1939/img v0.0.0-20210827153520-90cb4e9580a3/go.mod h1:FgTEOcosTWrkOr7++gbtPSj1rX5loRWrf/AL+hm3Cnw=
github.com/tidwall/gjson v1.8.0/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk=
github.com/tidwall/gjson v1.8.1 h1:8j5EE9Hrh3l9Od1OIEDAb7IpezNA20UdRngNAj5N0WU=
github.com/tidwall/gjson v1.8.1/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk=
github.com/tidwall/gjson v1.9.0 h1:+Od7AE26jAaMgVC31cQV/Ope5iKXulNMflrlB7k+F9E=
github.com/tidwall/gjson v1.9.0/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk=
github.com/tidwall/match v1.0.3 h1:FQUVvBImDutD8wJLN6c5eMzWtjgONK9MwIBCOrUJKeE=
@@ -84,7 +92,6 @@ 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/wdvxdr1123/ZeroBot v1.2.2 h1:BKEy3l80BMrQWpFWaII0AfFMyf9bqrB0TxfWhTdoV58=
github.com/wdvxdr1123/ZeroBot v1.2.2/go.mod h1:83nHtG8V5TAxPwH/LCDxLpZk4khIgs29dkr5TBWf7fc=
github.com/wdvxdr1123/ZeroBot v1.2.3 h1:Fu6aHr+91NRN48G9szJwyR0MhnTjG5lNMS0Wy0QX1Uo=
github.com/wdvxdr1123/ZeroBot v1.2.3/go.mod h1:83nHtG8V5TAxPwH/LCDxLpZk4khIgs29dkr5TBWf7fc=
@@ -92,6 +99,9 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
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/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/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/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -113,14 +123,13 @@ golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71 h1:ikCpsnYR+Ew0vu99XlDp55lGgDJdIMx3f4a18jfse/s=
golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210902050250-f475640dd07b h1:S7hKs0Flbq0bbc9xgYt4stIEG1zNDFqyrPwAX2Wj/sE=
golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
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/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=
@@ -142,15 +151,11 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
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.7 h1:Rvxffgx6LHSpGS6IO8bffSYN1wpPsWHEWY9CV95vpro=
modernc.org/cc/v3 v3.33.7/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/ccgo/v3 v3.9.5/go.mod h1:umuo2EP2oDSBnD3ckjaVUXMrmeAw8C8OSICVa0iFf60=
modernc.org/ccgo/v3 v3.9.6 h1:rCjLgu6iRxK2bqq8A0CCOnDP+tdA81LfbBUlM1L6ZIY=
modernc.org/ccgo/v3 v3.9.6/go.mod h1:KGOi0NhaT6CO19xeSXcpXBl0OkoD6T1U4dPd633G9Sg=
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=
@@ -158,9 +163,7 @@ modernc.org/ccgo/v3 v3.11.2 h1:gqa8PQ2v7SjrhHCgxUO5dzoAJWSLAveJqZTNkPCN0kc=
modernc.org/ccgo/v3 v3.11.2/go.mod h1:6kii3AptTDI+nUrM9RFBoIEUEisSWCbdczD9ZwQH2FE=
modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM=
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
modernc.org/libc v1.7.13-0.20210308123627-12f642a52bb8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
modernc.org/libc v1.9.8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
modernc.org/libc v1.9.11 h1:QUxZMs48Ahg2F7SN41aERvMfGLY2HU/ADnB9DC4Yts8=
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=
@@ -171,23 +174,18 @@ modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6
modernc.org/mathutil v1.4.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/mathutil v1.4.1 h1:ij3fYGe8zBF4Vu+g0oT7mB06r8sqGWKuJu1yXeR4by8=
modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/memory v1.0.4 h1:utMBrFcpnQDdNsmM6asmyH/FM9TqLPS7XF7otpJmrwM=
modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc=
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.12.0 h1:AMAOgk4CkblRJc6YLKSYtz3pZ6DW5wjQ1uYH/rN7/Kk=
modernc.org/sqlite v1.12.0/go.mod h1:ppqJ4cQ+R09YLzl9haEL9AYgj6wX8FcfwDTOI0nYykU=
modernc.org/sqlite v1.13.0 h1:cwhUj0jTBgPjk/demWheV+T6xi6ifTfsGIFKFq0g3Ck=
modernc.org/sqlite v1.13.0/go.mod h1:2qO/6jZJrcQaxFUHxOwa6Q6WfiGSsiVj6GXX0Ker+Jg=
modernc.org/strutil v1.1.1 h1:xv+J1BXY3Opl2ALrBwyfEikFAj8pmqcpnfmuwUwcozs=
modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw=
modernc.org/tcl v1.5.5 h1:N03RwthgTR/l/eQvz3UjfYnvVVj1G2sZqzFGfoD4HE4=
modernc.org/tcl v1.5.5/go.mod h1:ADkaTUuwukkrlhqwERyq0SM8OvyXo7+TjFz7yAF56EI=
modernc.org/tcl v1.5.9 h1:DZMfR+RDJRhcrmMEMTJgVIX+Wf5qhfVX0llI0rsc20w=
modernc.org/tcl v1.5.9/go.mod h1:bcwjvBJ2u0exY6K35eAmxXBBij5kXb1dHlAWmfhqThE=
modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk=
modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
modernc.org/z v1.0.1 h1:WyIDpEpAIx4Hel6q/Pcgj/VhaQV5XPJ2I6ryIYbjnpc=
modernc.org/z v1.0.1/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA=
modernc.org/z v1.1.2 h1:IjjzDsIFbl0wuF2KfwvdyUAJVwxD4iwZ6akLNiDoClM=
modernc.org/z v1.1.2/go.mod h1:sj9T1AGBG0dm6SCVzldPOHWrif6XBpooJtbttMn1+Js=

10
main.go
View File

@@ -18,6 +18,8 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_runcode" // 在线运行代码
// 娱乐类
_ "github.com/tdf1939/ZeroBot-Plugin-Gif/plugin_gif" // 制图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_false" // 服务器监控
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs" // 炉石
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft" // MCSManager
@@ -46,9 +48,9 @@ import (
var (
contents = []string{
"* OneBot + ZeroBot + Golang ",
"* Version 1.1.0 - 2021-08-06 23:36:29 +0800 CST",
"* Copyright © 2020 - 2021 Kanri, DawnNights, Fumiama, Suika",
"* OneBot + ZeroBot + Golang",
"* Version 1.1.5 - 2021-09-09 20:52:33 +0800 CST",
"* Copyright © 2020 - 2021 Kanri, DawnNights, Fumiama, Suika",
"* Project: https://github.com/FloatTech/ZeroBot-Plugin",
}
banner = strings.Join(contents, "\n")
@@ -87,7 +89,7 @@ func main() {
})
// 帮助
zero.OnFullMatchGroup([]string{"help", "/help", ".help", "菜单", "帮助"}, zero.OnlyToMe).SetBlock(true).SetPriority(999).
zero.OnFullMatchGroup([]string{"/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).FirstPriority().
Handle(func(ctx *zero.Ctx) {
ctx.Send(banner)
})

View File

@@ -11,6 +11,8 @@ import (
"github.com/FloatTech/AnimeAPI/picture"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
)
const (
@@ -31,7 +33,16 @@ var (
func init() { // 插件主体
// 初始化 classify
classify.Init(datapath)
zero.OnRegex(`^设置随机图片网址(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).SetPriority(20).
engine := control.Register("acgimage", &control.Options{
DisableOnDefault: false,
Help: "随机图片与AI点评\n" +
"- 随机图片(评级大于6的图将私发)\n" +
"- 直接随机(无r18检测务必小心仅管理可用)\n" +
"- 设置随机图片网址[url]\n" +
"- 太涩了(撤回最近发的图)\n" +
"- 评价图片(发送一张图片让bot评分)",
})
engine.OnRegex(`^设置随机图片网址(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).SetPriority(20).
Handle(func(ctx *zero.Ctx) {
url := ctx.State["regex_matched"].([]string)[1]
if !strings.HasPrefix(url, "http") {
@@ -42,7 +53,7 @@ func init() { // 插件主体
}
})
// 有保护的随机图片
zero.OnFullMatch("随机图片", zero.OnlyGroup).SetBlock(true).SetPriority(24).
engine.OnFullMatch("随机图片", zero.OnlyGroup).SetBlock(true).SetPriority(24).
Handle(func(ctx *zero.Ctx) {
if classify.CanVisit(5) {
go func() {
@@ -54,7 +65,7 @@ func init() { // 插件主体
}
})
// 直接随机图片无r18保护后果自负。如果出r18图可尽快通过发送"太涩了"撤回
zero.OnFullMatch("直接随机", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(24).
engine.OnFullMatch("直接随机", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(24).
Handle(func(ctx *zero.Ctx) {
if block {
ctx.Send("请稍后再试哦")
@@ -71,12 +82,12 @@ func init() { // 插件主体
}
})
// 撤回最后的直接随机图片
zero.OnFullMatch("太涩了").SetBlock(true).SetPriority(24).
engine.OnFullMatch("太涩了").SetBlock(true).SetPriority(24).
Handle(func(ctx *zero.Ctx) {
go cancel(ctx)
})
// 上传一张图进行评价
zero.OnKeywordGroup([]string{"评价图片"}, zero.OnlyGroup, picture.CmdMatch, picture.MustGiven).SetBlock(true).SetPriority(24).
engine.OnKeywordGroup([]string{"评价图片"}, zero.OnlyGroup, picture.CmdMatch, picture.MustGiven).SetBlock(true).SetPriority(24).
Handle(func(ctx *zero.Ctx) {
ctx.Send("少女祈祷中...")
for _, url := range ctx.State["image_url"].([]string) {
@@ -86,7 +97,7 @@ func init() { // 插件主体
}(url)
}
})
zero.OnRegex(`^给你点提示哦:(.*)$`, zero.OnlyPrivate).SetBlock(true).SetPriority(20).
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 {

View File

@@ -9,12 +9,19 @@ import (
"github.com/shirou/gopsutil/disk"
"github.com/shirou/gopsutil/mem"
"github.com/FloatTech/ZeroBot-Plugin/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() { // 插件主体
zero.OnFullMatchGroup([]string{"检查身体", "自检", "启动自检", "系统状态"}, zero.AdminPermission).
engine := control.Register("aifalse", &control.Options{
DisableOnDefault: false,
Help: "AIfalse\n" +
"- 查询计算机当前活跃度[检查身体|自检|启动自检|系统状态",
})
engine.OnFullMatchGroup([]string{"检查身体", "自检", "启动自检", "系统状态"}, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text(
"* CPU占用率: ", cpuPercent(), "%\n",

View File

@@ -8,6 +8,8 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
)
const (
@@ -18,7 +20,11 @@ func init() { // 插件主体
// TODO: 1.17 特性暂不增加
// rand.Seed(time.Now().UnixMicro())
rand.Seed(time.Now().UnixNano())
zero.OnFullMatchGroup([]string{"waifu", "随机waifu"}).SetPriority(10).
control.Register("aiwife", &control.Options{
DisableOnDefault: false,
Help: "AIWife\n" +
"- waifu|随机waifu",
}).OnFullMatchGroup([]string{"waifu", "随机waifu"}).SetPriority(10).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
miku := rand.Intn(100000) + 1
ctx.SendChain(message.At(ctx.Event.UserID), message.Image(fmt.Sprintf(bed, miku)))

View File

@@ -23,7 +23,7 @@ type follower struct {
// 开启日报推送
func init() {
zero.OnFullMatch("/开启粉丝日报", zero.AdminPermission).
engine.OnFullMatch("/开启粉丝日报", zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
fansDaily(ctx.Event.GroupID) // 群号传进去给下面发信息的函数
})

View File

@@ -8,11 +8,22 @@ import (
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
)
var engine *zero.Engine
// 查成分的
func init() {
zero.OnRegex(`^>user info\s(.{1,25})$`).
engine = control.Register("bilibili", &control.Options{
DisableOnDefault: false,
Help: "bilibili\n" +
"- >vup info [名字|uid]\n" +
"- >user info [名字|uid]\n" +
"- /开启粉丝日报",
})
engine.OnRegex(`^>user info\s(.{1,25})$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
keyword := ctx.State["regex_matched"].([]string)[1]
rest, err := uid(keyword)

View File

@@ -13,7 +13,7 @@ import (
// 查vup粉丝数据
func init() {
zero.OnRegex(`^>vup info\s?(.{1,25})$`).
engine.OnRegex(`^>vup info\s?(.{1,25})$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
keyword := ctx.State["regex_matched"].([]string)[1]
res, err := uid(keyword)

View File

@@ -8,25 +8,36 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/FloatTech/ZeroBot-Plugin/control"
"github.com/FloatTech/ZeroBot-Plugin/plugin_diana/data"
)
var engine *zero.Engine
func init() {
engine = control.Register("diana", &control.Options{
DisableOnDefault: false,
Help: "嘉然\n" +
"- 小作文\n" +
"- 发大病\n" +
"- 教你一篇小作文[作文]\n" +
"- [回复]查重",
})
// 随机发送一篇上面的小作文
zero.OnFullMatch("小作文", zero.OnlyToMe).
engine.OnFullMatch("小作文").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
rand.Seed(time.Now().UnixNano())
// 绕过第一行发病
ctx.Send((*data.Array)[rand.Intn(len(*data.Array)-1)+1])
})
// 逆天
zero.OnFullMatch("发大病", zero.OnlyToMe).
engine.OnFullMatch("发大病").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
// 第一行是发病
ctx.Send((*data.Array)[0])
})
// 增加小作文
zero.OnRegex(`^教你一篇小作文(.*)$`, zero.AdminPermission).
engine.OnRegex(`^教你一篇小作文(.*)$`, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
err := data.AddText(ctx.State["regex_matched"].([]string)[1])
if err != nil {

View File

@@ -93,6 +93,8 @@ func LoadText() error {
func AddText(txt string) error {
sum := md5.Sum(str2bytes(txt))
if txt != "" && !isin(sum) {
m.Lock()
defer m.Unlock()
compo.Array = append(compo.Array, txt)
md5s = append(md5s, sum)
return savecompo()
@@ -114,13 +116,10 @@ func savecompo() error {
data, err := compo.Marshal()
if err == nil {
if _, err := os.Stat(datapath); err == nil || os.IsExist(err) {
m.Lock()
defer m.Unlock()
f, err1 := os.OpenFile(pbfile, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
if err1 == nil {
_, err2 := f.Write(data)
f.Close()
return err2
}
return err1

View File

@@ -28,7 +28,7 @@ type zhiwang struct {
// 小作文查重: 回复要查的消息 查重
func init() {
zero.OnMessage(fullmatch("查重")).
engine.OnMessage(fullmatch("查重")).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
msg := ctx.Event.Message
if msg[0].Type == "reply" {

View File

@@ -12,11 +12,18 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
"github.com/tidwall/gjson"
)
func init() { // 插件主体
zero.OnRegex(`^>github\s(-.{1,10}? )?(.*)$`).SetBlock(true).FirstPriority().
control.Register("github", &control.Options{
DisableOnDefault: false,
Help: "GitHub仓库搜索\n" +
"- >github [xxx]\n" +
"- >github -p [xxx]",
}).OnRegex(`^>github\s(-.{1,10}? )?(.*)$`).SetBlock(true).FirstPriority().
Handle(func(ctx *zero.Ctx) {
// 发送请求
header := http.Header{

View File

@@ -12,6 +12,8 @@ import (
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
)
const cachedir = "data/hs/"
@@ -27,7 +29,15 @@ func init() {
if err != nil {
panic(err)
}
zero.OnRegex(`^搜卡(.+)$`).
engine := control.Register("hs", &control.Options{
DisableOnDefault: false,
Help: "炉石\n" +
"- 搜卡[xxxx]\n" +
"- [卡组代码xxx]\n" +
"- 更多搜卡指令参数https://hs.fbigame.com/misc/searchhelp",
})
engine.OnRegex(`^搜卡(.+)$`).
SetBlock(true).SetPriority(20).Handle(func(ctx *zero.Ctx) {
List := ctx.State["regex_matched"].([]string)[1]
g := sh(List)
@@ -67,7 +77,7 @@ func init() {
}
})
// 卡组
zero.OnRegex(`^[\s\S]*?(AAE[a-zA-Z0-9/\+=]{70,})[\s\S]*$`).
engine.OnRegex(`^[\s\S]*?(AAE[a-zA-Z0-9/\+=]{70,})[\s\S]*$`).
SetBlock(true).SetPriority(20).Handle(func(ctx *zero.Ctx) {
fmt.Print("成功")
List := ctx.State["regex_matched"].([]string)[1]

View File

@@ -10,6 +10,8 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
)
type resultjson struct {
@@ -59,7 +61,11 @@ type resultjson struct {
}
func init() {
zero.OnRegex(`^来张 (.*)$`, zero.AdminPermission).
control.Register("imgfinder", &control.Options{
DisableOnDefault: false,
Help: "关键字搜图\n" +
"- 来张 [xxx]",
}).OnRegex(`^来张 (.*)$`, zero.AdminPermission).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
keyword := ctx.State["regex_matched"].([]string)[1]
soutujson := soutuapi(keyword)

View File

@@ -9,6 +9,8 @@ import (
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
)
const (
@@ -21,7 +23,11 @@ var (
)
func init() {
zero.OnFullMatch("来份萝莉").
control.Register("lolicon", &control.Options{
DisableOnDefault: false,
Help: "lolicon\n" +
"- 来份萝莉",
}).OnFullMatch("来份萝莉").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
go func() {
for i := 0; i < min(cap(queue)-len(queue), 2); i++ {

View File

@@ -7,6 +7,7 @@ import (
"strings"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension"
"github.com/wdvxdr1123/ZeroBot/message"
)
@@ -36,30 +37,28 @@ type resultjson struct {
} `json:"players"`
}
var (
servers = make(map[string]string)
)
func init() {
zero.OnRegex(`^/list (.*)$`).
// 这里填对应mc服务器的登录地址
servers["ftbi"] = "115.28.186.22:25710"
servers["ges"] = "115.28.186.22:25701"
engine.OnCommand("mclist").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
model := extension.CommandModel{}
_ = ctx.Parse(&model)
// 支持多个服务器
switch ctx.State["regex_matched"].([]string)[1] {
case "ftbi": // 这里对应触发指令里的服务器名称
ftbijson := infoapi("115.28.186.22:25710") // 这里填对应mc服务器的登录地址
var str = ftbijson.Players.List
cs := strings.Join(str, "\n")
ctx.SendChain(message.Text(
"服务器名字: ", ftbijson.Motd.Raw[0], "\n",
"在线人数: ", ftbijson.Players.Online, "/", ftbijson.Players.Max, "\n",
"以下为玩家名字: ", "\n", cs,
))
case "ges": // 这里对应触发指令里的服务器名称
gesjson := infoapi("115.28.186.22:25701") // 这里填对应mc服务器的登录地址
var str = gesjson.Players.List
cs := strings.Join(str, "\n")
ctx.SendChain(message.Text(
"服务器名字: ", gesjson.Motd.Raw[0], "\n",
"在线人数: ", gesjson.Players.Online, "/", gesjson.Players.Max, "\n",
"以下为玩家名字: ", "\n", cs,
))
}
gesjson := infoapi(servers[model.Args])
var str = gesjson.Players.List
cs := strings.Join(str, "\n")
ctx.SendChain(message.Text(
"服务器名字: ", gesjson.Motd.Raw[0], "\n",
"在线人数: ", gesjson.Players.Online, "/", gesjson.Players.Max, "\n",
"以下为玩家名字: ", "\n", cs,
))
})
}

View File

@@ -7,36 +7,50 @@ import (
"net/http"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
)
// 此功能实现依赖MCSManager项目对服务器的管理apimc服务器如果没有在该管理平台部署此功能无效
// 项目地址: https://github.com/Suwings/MCSManager
// 项目的api文档: https://github.com/Suwings/MCSManager/wiki/API-Documentation
func init() {
zero.OnRegex(`^/start (.*)$`).
Handle(func(ctx *zero.Ctx) {
name := ctx.State["regex_matched"].([]string)[1]
ctx.SendChain(message.Text("开启服务器: ", name, "....."))
result := start(name)
ctx.Send(result)
})
}
const api = "http://your.addr:23333/api/start_server/%s/?apikey=apikey"
var engine *zero.Engine
func init() {
zero.OnRegex(`^/stop (.*)$`).
engine = control.Register("minecraft", &control.Options{
DisableOnDefault: false,
Help: "minecraft\n" +
"- /mcstart xxx\n" +
"- /mcstop xxx\n" +
"- /mclist servername\n" +
"- https://github.com/Suwings/MCSManager",
})
engine.OnCommand("mcstart").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
name := ctx.State["regex_matched"].([]string)[1]
ctx.SendChain(message.Text("关闭服务器: ", name, "....."))
result := stop(name)
model := extension.CommandModel{}
_ = ctx.Parse(&model)
ctx.SendChain(message.Text("开启服务器: ", model.Args, "....."))
result := start(model.Args)
ctx.Send(result)
})
engine.OnCommand("mcstop").SetBlock(true).
Handle(func(ctx *zero.Ctx) {
model := extension.CommandModel{}
_ = ctx.Parse(&model)
ctx.SendChain(message.Text("开启服务器: ", model.Args, "....."))
result := stop(model.Args)
ctx.Send(result)
})
}
// 开启服务器的api请求
func start(name string) string {
url := fmt.Sprintf("http://your.addr:23333/api/start_server/%s/?apikey=apikey", name)
url := fmt.Sprintf(api, name)
client := &http.Client{}
req, err := http.NewRequest("GET", url, nil)
if err != nil {
@@ -57,7 +71,7 @@ func start(name string) string {
// 关闭服务器的api请求
func stop(name string) string {
url := fmt.Sprintf("http://your.addr:23333/api/stop_server/%s/?apikey=apikey", name)
url := fmt.Sprintf(api, name)
client := &http.Client{}
req, err := http.NewRequest("GET", url, nil)
if err != nil {

View File

@@ -15,12 +15,21 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
)
var limit = rate.NewManager(time.Minute*3, 5)
func init() {
zero.OnRegex("^(.{0,2})点歌(.{1,25})$").SetBlock(true).FirstPriority().
control.Register("music", &control.Options{
DisableOnDefault: false,
Help: "点歌\n" +
"- 点歌[xxx]\n" +
"- 网易点歌[xxx]\n" +
"- 酷我点歌[xxx]\n" +
"- 酷狗点歌[xxx]",
}).OnRegex("^(.{0,2})点歌(.{1,25})$").SetBlock(true).FirstPriority().
Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.UserID).Acquire() {
ctx.Send("请稍后重试0x0...")

View File

@@ -8,6 +8,8 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
)
const (
@@ -18,7 +20,11 @@ func init() { // 插件主体
// TODO: 1.17 特性暂不增加
// rand.Seed(time.Now().UnixMicro())
rand.Seed(time.Now().UnixNano())
zero.OnFullMatchGroup([]string{"求签", "运势", "占卜"}, zero.OnlyToMe).SetPriority(10).
control.Register("omikuji", &control.Options{
DisableOnDefault: false,
Help: "浅草寺求签\n" +
"- 求签|运势|占卜",
}).OnFullMatchGroup([]string{"求签", "运势", "占卜"}).SetPriority(10).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
miku := rand.Intn(100) + 1
ctx.SendChain(

View File

@@ -17,28 +17,24 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
)
var (
prio = 3
prio = 100
bucket = rate.NewManager(time.Minute, 20) // 青云客接口回复
enable = true
engine *zero.Engine
)
func init() { // 插件主体
// 开关
zero.OnFullMatch("开启自动回复", zero.SuperUserPermission).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
enable = true
ctx.SendChain(message.Text("自动回复开启"))
})
zero.OnFullMatch("关闭自动回复", zero.SuperUserPermission).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
enable = false
ctx.SendChain(message.Text("自动回复关闭"))
})
// 回复
zero.OnRegex("(^.{1,30}$)", zero.OnlyToMe, switchQYK()).SetBlock(false).SetPriority(prio).
engine = control.Register("qingyunke", &control.Options{
DisableOnDefault: false,
Help: "青云客\n" +
"- @Bot 任意文本(任意一句话回复)",
})
// 回复 匹配中文、英文、数字、空格但不包括下划线等符号
engine.OnRegex("^([\u4E00-\u9FA5A-Za-z0-9\\s]{1,30})", zero.OnlyToMe).SetBlock(true).SetPriority(prio).
Handle(func(ctx *zero.Ctx) {
if !bucket.Load(ctx.Event.UserID).Acquire() {
// 频繁触发,不回复
@@ -62,6 +58,7 @@ func init() { // 插件主体
textReply = reply
}
textReply = strings.ReplaceAll(textReply, "菲菲", zero.BotConfig.NickName[0])
textReply = strings.ReplaceAll(textReply, "{br}", "\n")
// 回复
time.Sleep(time.Second * 1)
if ctx.Event.MessageType == "group" {
@@ -152,9 +149,3 @@ func getAgent() string {
len1 := len(agent)
return agent[r.Intn(len1)]
}
func switchQYK() zero.Rule {
return func(ctx *zero.Ctx) bool {
return enable
}
}

View File

@@ -13,11 +13,12 @@ import (
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
"github.com/tidwall/gjson"
)
var (
enable = true
limit = rate.NewManager(time.Minute*3, 5)
templates = map[string]string{
"py2": "print 'Hello World!'",
@@ -92,40 +93,18 @@ var (
)
func init() {
zero.OnFullMatch(">runcode help").SetBlock(true).FirstPriority().
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text(
"使用说明: ", "\n",
">runcode [language] [code block]", "\n",
"模板查看: ", "\n",
">runcode [language] help", "\n",
"支持语种: ", "\n",
"Go || Python || C/C++ || C# || Java || Lua ", "\n",
"JavaScript || TypeScript || PHP || Shell ", "\n",
"Kotlin || Rust || Erlang || Ruby || Swift ", "\n",
"R || VB || Py2 || Perl || Pascal || Scala ", "\n",
))
})
zero.OnFullMatch(">runcode on", zero.AdminPermission).SetBlock(true).FirstPriority().
Handle(func(ctx *zero.Ctx) {
enable = true
ctx.SendChain(
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
message.Text("在线运行代码功能已启用"),
)
})
zero.OnFullMatch(">runcode off", zero.AdminPermission).SetBlock(true).FirstPriority().
Handle(func(ctx *zero.Ctx) {
enable = false
ctx.SendChain(
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
message.Text("在线运行代码功能已禁用"),
)
})
zero.OnRegex(`^>runcode\s(.+?)\s([\s\S]+)$`).SetBlock(true).SecondPriority().
control.Register("runcode", &control.Options{
DisableOnDefault: false,
Help: "在线代码运行: \n" +
">runcode [language] [code block]\n" +
"模板查看: \n" +
">runcode [language] help\n" +
"支持语种: \n" +
"Go || Python || C/C++ || C# || Java || Lua \n" +
"JavaScript || TypeScript || PHP || Shell \n" +
"Kotlin || Rust || Erlang || Ruby || Swift \n" +
"R || VB || Py2 || Perl || Pascal || Scala",
}).OnRegex(`^>runcode\s(.+?)\s([\s\S]+)$`).SetBlock(true).SecondPriority().
Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.UserID).Acquire() {
ctx.Send("请稍后重试0x0...")
@@ -139,39 +118,31 @@ func init() {
message.Text("语言不是受支持的编程语种呢~"),
)
} else {
if !enable {
// 运行代码被禁用
// 执行运行
block := ctx.State["regex_matched"].([]string)[2]
block = message.UnescapeCQCodeText(block)
if block == "help" {
// 输出模板
ctx.SendChain(
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
message.Text("在线运行代码功能已被禁用"),
message.Text("> ", ctx.Event.Sender.NickName, " ", language, "-template:\n"),
message.Text(
">runcode ", language, "\n",
templates[language],
),
)
} else {
// 执行运行
block := ctx.State["regex_matched"].([]string)[2]
block = message.UnescapeCQCodeText(block)
if block == "help" {
// 输出模板
if output, err := runCode(block, runType); err != nil {
// 运行失败
ctx.SendChain(
message.Text("> ", ctx.Event.Sender.NickName, " ", language, "-template:\n"),
message.Text(
">runcode ", language, "\n",
templates[language],
),
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
message.Text("ERROR: ", err),
)
} else {
if output, err := runCode(block, runType); err != nil {
// 运行失败
ctx.SendChain(
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
message.Text("ERROR: ", err),
)
} else {
// 运行成功
ctx.SendChain(
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
message.Text(output),
)
}
// 运行成功
ctx.SendChain(
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
message.Text(output),
)
}
}
}

View File

@@ -13,11 +13,19 @@ import (
"github.com/FloatTech/AnimeAPI/picture"
"github.com/FloatTech/AnimeAPI/pixiv"
"github.com/FloatTech/AnimeAPI/saucenao"
"github.com/FloatTech/ZeroBot-Plugin/control"
)
func init() { // 插件主体
engine := control.Register("saucenao", &control.Options{
DisableOnDefault: false,
Help: "搜图\n" +
"- 以图搜图|搜索图片|以图识图[图片]\n" +
"- 搜图[P站图片ID]",
})
// 根据 PID 搜图
zero.OnRegex(`^搜图(\d+)$`).SetBlock(true).FirstPriority().
engine.OnRegex(`^搜图(\d+)$`).SetBlock(true).FirstPriority().
Handle(func(ctx *zero.Ctx) {
id, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[1], 10, 64)
ctx.Send("少女祈祷中......")
@@ -27,24 +35,28 @@ func init() { // 插件主体
ctx.SendChain(message.Text("ERROR: ", err))
return
}
// 改用 i.pixiv.cat 镜像站
link := illust.ImageUrls
link = strings.ReplaceAll(link, "i.pximg.net", "i.pixiv.cat")
// 发送搜索结果
ctx.SendChain(
message.Image(link),
message.Text(
"\n",
"标题:", illust.Title, "\n",
"插画ID", illust.Pid, "\n",
"画师", illust.UserName, "\n",
"画师ID", illust.UserId, "\n",
"直链", "https://pixivel.moe/detail?id=", illust.Pid,
),
)
if illust.Pid > 0 {
// 改用 i.pixiv.cat 镜像站
link := illust.ImageUrls
link = strings.ReplaceAll(link, "i.pximg.net", "i.pixiv.cat")
// 发送搜索结果
ctx.SendChain(
message.Image(link),
message.Text(
"\n",
"标题", illust.Title, "\n",
"插画ID", illust.Pid, "\n",
"画师:", illust.UserName, "\n",
"画师ID", illust.UserId, "\n",
"直链:", "https://pixivel.moe/detail?id=", illust.Pid,
),
)
} else {
ctx.Send("图片不存在!")
}
})
// 以图搜图
zero.OnKeywordGroup([]string{"以图搜图", "搜索图片", "以图识图"}, picture.CmdMatch, picture.MustGiven).SetBlock(true).FirstPriority().
engine.OnKeywordGroup([]string{"以图搜图", "搜索图片", "以图识图"}, picture.CmdMatch, picture.MustGiven).SetBlock(true).FirstPriority().
Handle(func(ctx *zero.Ctx) {
// 开始搜索图片
ctx.Send("少女祈祷中......")

View File

@@ -16,12 +16,15 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
. "github.com/FloatTech/ZeroBot-Plugin/data"
)
// Pools 图片缓冲池
type imgpool struct {
Lock sync.Mutex
DB *sqlite
DB *Sqlite
Path string
Group int64
List []string
@@ -37,7 +40,7 @@ const (
// NewPoolsCache 返回一个缓冲池对象
func newPools() *imgpool {
cache := &imgpool{
DB: &sqlite{DBPath: "data/SetuTime/SetuTime.db"},
DB: &Sqlite{DBPath: "data/SetuTime/SetuTime.db"},
Path: "data/SetuTime/cache/",
Group: 0,
List: []string{"涩图", "二次元", "风景", "车万"}, // 可以自己加类别,得自己加图片进数据库
@@ -71,7 +74,7 @@ func newPools() *imgpool {
}
}
for i := range cache.List {
if err := cache.DB.create(cache.List[i], &pixiv.Illust{}); err != nil {
if err := cache.DB.Create(cache.List[i], &pixiv.Illust{}); err != nil {
panic(err)
}
}
@@ -84,7 +87,15 @@ var (
)
func init() { // 插件主体
zero.OnRegex(`^来份(.*)$`, firstValueInList(pool.List)).SetBlock(true).SetPriority(20).
engine := control.Register("setutime", &control.Options{
DisableOnDefault: false,
Help: "涩图\n" +
"- 来份[涩图/二次元/风景/车万]\n" +
"- 添加[涩图/二次元/风景/车万][P站图片ID]\n" +
"- 删除[涩图/二次元/风景/车万][P站图片ID]\n" +
"- >setu status",
})
engine.OnRegex(`^来份(.*)$`, firstValueInList(pool.List)).SetBlock(true).SetPriority(20).
Handle(func(ctx *zero.Ctx) {
if !limit.Load(ctx.Event.UserID).Acquire() {
ctx.SendChain(message.Text("请稍后重试0x0..."))
@@ -97,7 +108,7 @@ func init() { // 插件主体
for i := 0; i < times; i++ {
illust := &pixiv.Illust{}
// 查询出一张图片
if err := pool.DB.find(imgtype, illust, "ORDER BY RANDOM() limit 1"); err != nil {
if err := pool.DB.Find(imgtype, illust, "ORDER BY RANDOM() limit 1"); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
continue
}
@@ -128,7 +139,7 @@ func init() { // 插件主体
}
})
zero.OnRegex(`^添加(.*?)(\d+)$`, firstValueInList(pool.List), zero.SuperUserPermission).SetBlock(true).SetPriority(21).
engine.OnRegex(`^添加(.*?)(\d+)$`, firstValueInList(pool.List), zero.SuperUserPermission).SetBlock(true).SetPriority(21).
Handle(func(ctx *zero.Ctx) {
var (
imgtype = ctx.State["regex_matched"].([]string)[1]
@@ -152,21 +163,21 @@ func init() { // 插件主体
return
}
// 添加插画到对应的数据库table
if err := pool.DB.insert(imgtype, illust); err != nil {
if err := pool.DB.Insert(imgtype, illust); err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
}
ctx.Send("添加成功")
})
zero.OnRegex(`^删除(.*?)(\d+)$`, firstValueInList(pool.List), zero.SuperUserPermission).SetBlock(true).SetPriority(22).
engine.OnRegex(`^删除(.*?)(\d+)$`, firstValueInList(pool.List), zero.SuperUserPermission).SetBlock(true).SetPriority(22).
Handle(func(ctx *zero.Ctx) {
var (
imgtype = ctx.State["regex_matched"].([]string)[1]
id, _ = strconv.ParseInt(ctx.State["regex_matched"].([]string)[2], 10, 64)
)
// 查询数据库
if err := pool.DB.del(imgtype, fmt.Sprintf("WHERE pid=%d", id)); err != nil {
if err := pool.DB.Del(imgtype, fmt.Sprintf("WHERE pid=%d", id)); err != nil {
ctx.Send(fmt.Sprintf("ERROR: %v", err))
return
}
@@ -174,11 +185,11 @@ func init() { // 插件主体
})
// 查询数据库涩图数量
zero.OnFullMatchGroup([]string{">setu status"}).SetBlock(true).SetPriority(23).
engine.OnFullMatchGroup([]string{">setu status"}).SetBlock(true).SetPriority(23).
Handle(func(ctx *zero.Ctx) {
state := []string{"[SetuTime]"}
for i := range pool.List {
num, err := pool.DB.count(pool.List[i])
num, err := pool.DB.Count(pool.List[i])
if err != nil {
num = 0
}

View File

@@ -9,6 +9,8 @@ import (
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/extension/rate"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/FloatTech/ZeroBot-Plugin/control"
)
var (
@@ -17,10 +19,18 @@ var (
)
func init() {
zero.OnPrefix("异世界转生", number(587874)).SetBlock(true).FirstPriority().Handle(handle)
zero.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).FirstPriority().Handle(handle)
zero.OnPrefix("卖萌", number(360578)).SetBlock(true).FirstPriority().Handle(handle)
zero.OnPrefix("抽老婆", number(1075116)).SetBlock(true).FirstPriority().Handle(handle)
engine := control.Register("shindan", &control.Options{
DisableOnDefault: false,
Help: "shindan\n" +
"- 今天是什么少女[@xxx]\n" +
"- 异世界转生[@xxx]\n" +
"- 卖萌[@xxx]\n" +
"- 抽老婆[@xxx]",
})
engine.OnPrefix("异世界转生", number(587874)).SetBlock(true).FirstPriority().Handle(handle)
engine.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).FirstPriority().Handle(handle)
engine.OnPrefix("卖萌", number(360578)).SetBlock(true).FirstPriority().Handle(handle)
engine.OnPrefix("抽老婆", number(1075116)).SetBlock(true).FirstPriority().Handle(handle)
}
// shindanmaker 处理函数