mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
Merge pull request #69 from Yiwen-Chan/master
🎨 ctx.Send -> ctx.SendChain
This commit is contained in:
commit
ac73087f93
@ -69,6 +69,7 @@ func (m *Control) Disable(groupID int64) {
|
|||||||
m.Unlock()
|
m.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsEnabledIn 开启群
|
||||||
func (m *Control) IsEnabledIn(gid int64) bool {
|
func (m *Control) IsEnabledIn(gid int64) bool {
|
||||||
m.RLock()
|
m.RLock()
|
||||||
var c grpcfg
|
var c grpcfg
|
||||||
@ -140,10 +141,10 @@ func init() {
|
|||||||
_ = ctx.Parse(&model)
|
_ = ctx.Parse(&model)
|
||||||
service, ok := Lookup(model.Args)
|
service, ok := Lookup(model.Args)
|
||||||
if !ok {
|
if !ok {
|
||||||
ctx.Send("没有找到指定服务!")
|
ctx.SendChain(message.Text("没有找到指定服务!"))
|
||||||
}
|
}
|
||||||
service.Enable(ctx.Event.GroupID)
|
service.Enable(ctx.Event.GroupID)
|
||||||
ctx.Send(message.Text("已启用服务: " + model.Args))
|
ctx.SendChain(message.Text("已启用服务: " + model.Args))
|
||||||
})
|
})
|
||||||
|
|
||||||
zero.OnCommandGroup([]string{"禁用", "disable"}, zero.AdminPermission, zero.OnlyGroup).
|
zero.OnCommandGroup([]string{"禁用", "disable"}, zero.AdminPermission, zero.OnlyGroup).
|
||||||
@ -152,10 +153,10 @@ func init() {
|
|||||||
_ = ctx.Parse(&model)
|
_ = ctx.Parse(&model)
|
||||||
service, ok := Lookup(model.Args)
|
service, ok := Lookup(model.Args)
|
||||||
if !ok {
|
if !ok {
|
||||||
ctx.Send("没有找到指定服务!")
|
ctx.SendChain(message.Text("没有找到指定服务!"))
|
||||||
}
|
}
|
||||||
service.Disable(ctx.Event.GroupID)
|
service.Disable(ctx.Event.GroupID)
|
||||||
ctx.Send(message.Text("已关闭服务: " + model.Args))
|
ctx.SendChain(message.Text("已关闭服务: " + model.Args))
|
||||||
})
|
})
|
||||||
|
|
||||||
zero.OnCommandGroup([]string{"用法", "usage"}, zero.AdminPermission, zero.OnlyGroup).
|
zero.OnCommandGroup([]string{"用法", "usage"}, zero.AdminPermission, zero.OnlyGroup).
|
||||||
@ -164,12 +165,12 @@ func init() {
|
|||||||
_ = ctx.Parse(&model)
|
_ = ctx.Parse(&model)
|
||||||
service, ok := Lookup(model.Args)
|
service, ok := Lookup(model.Args)
|
||||||
if !ok {
|
if !ok {
|
||||||
ctx.Send("没有找到指定服务!")
|
ctx.SendChain(message.Text("没有找到指定服务!"))
|
||||||
}
|
}
|
||||||
if service.options.Help != "" {
|
if service.options.Help != "" {
|
||||||
ctx.Send(service.options.Help)
|
ctx.SendChain(message.Text(service.options.Help))
|
||||||
} else {
|
} else {
|
||||||
ctx.Send("该服务无帮助!")
|
ctx.SendChain(message.Text("该服务无帮助!"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -187,7 +188,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
ctx.Send(message.Text(msg))
|
ctx.SendChain(message.Text(msg))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
main.go
3
main.go
@ -51,6 +51,7 @@ import (
|
|||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/driver"
|
"github.com/wdvxdr1123/ZeroBot/driver"
|
||||||
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -121,7 +122,7 @@ func main() {
|
|||||||
// 帮助
|
// 帮助
|
||||||
zero.OnFullMatchGroup([]string{"/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).FirstPriority().
|
zero.OnFullMatchGroup([]string{"/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).FirstPriority().
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
ctx.Send(banner)
|
ctx.SendChain(message.Text(banner))
|
||||||
})
|
})
|
||||||
select {}
|
select {}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,10 +46,10 @@ func init() { // 插件主体
|
|||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
url := ctx.State["regex_matched"].([]string)[1]
|
url := ctx.State["regex_matched"].([]string)[1]
|
||||||
if !strings.HasPrefix(url, "http") {
|
if !strings.HasPrefix(url, "http") {
|
||||||
ctx.Send("URL非法!")
|
ctx.SendChain(message.Text("URL非法!"))
|
||||||
} else {
|
} else {
|
||||||
randapi = url
|
randapi = url
|
||||||
ctx.Send("设置好啦")
|
ctx.SendChain(message.Text("设置好啦"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 有保护的随机图片
|
// 有保护的随机图片
|
||||||
@ -61,14 +61,14 @@ func init() { // 插件主体
|
|||||||
replyClass(ctx, dhash, class, false, lastvisit, comment)
|
replyClass(ctx, dhash, class, false, lastvisit, comment)
|
||||||
}()
|
}()
|
||||||
} else {
|
} else {
|
||||||
ctx.Send("你太快啦!")
|
ctx.SendChain(message.Text("你太快啦!"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 直接随机图片,无r18保护,后果自负。如果出r18图可尽快通过发送"太涩了"撤回
|
// 直接随机图片,无r18保护,后果自负。如果出r18图可尽快通过发送"太涩了"撤回
|
||||||
engine.OnFullMatch("直接随机", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(24).
|
engine.OnFullMatch("直接随机", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(24).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if block {
|
if block {
|
||||||
ctx.Send("请稍后再试哦")
|
ctx.SendChain(message.Text("请稍后再试哦"))
|
||||||
} else if randapi != "" {
|
} else if randapi != "" {
|
||||||
block = true
|
block = true
|
||||||
var url string
|
var url string
|
||||||
@ -77,7 +77,7 @@ func init() { // 插件主体
|
|||||||
} else {
|
} else {
|
||||||
url = randapi
|
url = randapi
|
||||||
}
|
}
|
||||||
setLastMsg(ctx.Event.GroupID, ctx.Send(message.Image(url).Add("cache", "0")))
|
setLastMsg(ctx.Event.GroupID, ctx.SendChain(message.Image(url).Add("cache", "0")))
|
||||||
block = false
|
block = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -89,7 +89,7 @@ func init() { // 插件主体
|
|||||||
// 上传一张图进行评价
|
// 上传一张图进行评价
|
||||||
engine.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) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
ctx.Send("少女祈祷中...")
|
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||||
for _, url := range ctx.State["image_url"].([]string) {
|
for _, url := range ctx.State["image_url"].([]string) {
|
||||||
go func(target string) {
|
go func(target string) {
|
||||||
class, lastvisit, dhash, comment := classify.Classify(target, true)
|
class, lastvisit, dhash, comment := classify.Classify(target, true)
|
||||||
@ -101,7 +101,7 @@ func init() { // 插件主体
|
|||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
dhash := ctx.State["regex_matched"].([]string)[1]
|
dhash := ctx.State["regex_matched"].([]string)[1]
|
||||||
if len(dhash) == 5*3 {
|
if len(dhash) == 5*3 {
|
||||||
ctx.Send(message.Image(apihead + dhash))
|
ctx.SendChain(message.Image(apihead + dhash))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -124,19 +124,18 @@ func replyClass(ctx *zero.Ctx, dhash string, class int, noimg bool, lv int64, co
|
|||||||
if dhash != "" && !noimg {
|
if dhash != "" && !noimg {
|
||||||
b14, err3 := url.QueryUnescape(dhash)
|
b14, err3 := url.QueryUnescape(dhash)
|
||||||
if err3 == nil {
|
if err3 == nil {
|
||||||
ctx.Send(comment + "\n给你点提示哦:" + b14)
|
ctx.SendChain(message.Text(comment + "\n给你点提示哦:" + b14))
|
||||||
ctx.Event.GroupID = 0
|
ctx.Event.GroupID = 0
|
||||||
ctx.Send(img)
|
ctx.SendChain(message.Text(img))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx.Send(comment)
|
ctx.SendChain(message.Text(comment))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
comment := message.Text(comment)
|
|
||||||
if !noimg {
|
if !noimg {
|
||||||
ctx.SendChain(img, comment)
|
ctx.SendChain(img, message.Text(comment))
|
||||||
} else {
|
} else {
|
||||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), comment)
|
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(comment))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,9 +35,9 @@ func init() { // 插件主体
|
|||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
err := os.RemoveAll("data/cache/*")
|
err := os.RemoveAll("data/cache/*")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Send("错误: " + err.Error())
|
ctx.SendChain(message.Text("错误: ", err.Error()))
|
||||||
} else {
|
} else {
|
||||||
ctx.Send("成功!")
|
ctx.SendChain(message.Text("成功!"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,11 +2,11 @@
|
|||||||
package diana
|
package diana
|
||||||
|
|
||||||
import (
|
import (
|
||||||
fmt "fmt"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
|
|
||||||
"github.com/FloatTech/ZeroBot-Plugin/control"
|
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||||
"github.com/FloatTech/ZeroBot-Plugin/plugin_diana/data"
|
"github.com/FloatTech/ZeroBot-Plugin/plugin_diana/data"
|
||||||
@ -28,22 +28,22 @@ func init() {
|
|||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
// 绕过第一行发病
|
// 绕过第一行发病
|
||||||
ctx.Send((*data.Array)[rand.Intn(len(*data.Array)-1)+1])
|
ctx.SendChain(message.Text((*data.Array)[rand.Intn(len(*data.Array)-1)+1]))
|
||||||
})
|
})
|
||||||
// 逆天
|
// 逆天
|
||||||
engine.OnFullMatch("发大病").SetBlock(true).
|
engine.OnFullMatch("发大病").SetBlock(true).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
// 第一行是发病
|
// 第一行是发病
|
||||||
ctx.Send((*data.Array)[0])
|
ctx.SendChain(message.Text((*data.Array)[0]))
|
||||||
})
|
})
|
||||||
// 增加小作文
|
// 增加小作文
|
||||||
engine.OnRegex(`^教你一篇小作文(.*)$`, zero.AdminPermission).SetBlock(true).
|
engine.OnRegex(`^教你一篇小作文(.*)$`, zero.AdminPermission).SetBlock(true).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
err := data.AddText(ctx.State["regex_matched"].([]string)[1])
|
err := data.AddText(ctx.State["regex_matched"].([]string)[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Send(fmt.Sprintf("ERROR: %v", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
} else {
|
} else {
|
||||||
ctx.Send("记住啦!")
|
ctx.SendChain(message.Text("记住啦!"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
// Package diana 嘉然相关
|
||||||
package diana
|
package diana
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -37,12 +38,12 @@ func init() {
|
|||||||
zhiwangjson := zhiwangapi(msg)
|
zhiwangjson := zhiwangapi(msg)
|
||||||
|
|
||||||
if zhiwangjson == nil || zhiwangjson.Code != 0 {
|
if zhiwangjson == nil || zhiwangjson.Code != 0 {
|
||||||
ctx.Send("api返回错误")
|
ctx.SendChain(message.Text("api返回错误"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(zhiwangjson.Data.Related) == 0 {
|
if len(zhiwangjson.Data.Related) == 0 {
|
||||||
ctx.Send("枝网没搜到,查重率为0%,我的评价是:一眼真")
|
ctx.SendChain(message.Text("枝网没搜到,查重率为0%,我的评价是:一眼真"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -58,7 +58,7 @@ func init() { // 插件主体
|
|||||||
// 菜单
|
// 菜单
|
||||||
zero.OnFullMatch("群管系统", zero.AdminPermission).SetBlock(true).FirstPriority().
|
zero.OnFullMatch("群管系统", zero.AdminPermission).SetBlock(true).FirstPriority().
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
ctx.Send(hint)
|
ctx.SendChain(message.Text(hint))
|
||||||
})
|
})
|
||||||
// 升为管理
|
// 升为管理
|
||||||
zero.OnRegex(`^升为管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
|
zero.OnRegex(`^升为管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
|
||||||
@ -254,9 +254,9 @@ func init() { // 插件主体
|
|||||||
ts.Grpid = uint64(ctx.Event.GroupID)
|
ts.Grpid = uint64(ctx.Event.GroupID)
|
||||||
if ts.Enable {
|
if ts.Enable {
|
||||||
go timer.RegisterTimer(ts, true)
|
go timer.RegisterTimer(ts, true)
|
||||||
ctx.Send("记住了~")
|
ctx.SendChain(message.Text("记住了~"))
|
||||||
} else {
|
} else {
|
||||||
ctx.Send("参数非法!")
|
ctx.SendChain(message.Text("参数非法!"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -273,9 +273,9 @@ func init() { // 插件主体
|
|||||||
t.Enable = false
|
t.Enable = false
|
||||||
delete(*timer.Timers, ti) // 避免重复取消
|
delete(*timer.Timers, ti) // 避免重复取消
|
||||||
_ = timer.SaveTimers()
|
_ = timer.SaveTimers()
|
||||||
ctx.Send("取消成功~")
|
ctx.SendChain(message.Text("取消成功~"))
|
||||||
} else {
|
} else {
|
||||||
ctx.Send("没有这个定时器哦~")
|
ctx.SendChain(message.Text("没有这个定时器哦~"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -283,7 +283,7 @@ func init() { // 插件主体
|
|||||||
zero.OnFullMatch("列出所有提醒", zero.AdminPermission).SetBlock(true).SetPriority(40).
|
zero.OnFullMatch("列出所有提醒", zero.AdminPermission).SetBlock(true).SetPriority(40).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if ctx.Event.GroupID > 0 {
|
if ctx.Event.GroupID > 0 {
|
||||||
ctx.Send(fmt.Sprint(timer.ListTimers(uint64(ctx.Event.GroupID))))
|
ctx.SendChain(message.Text(timer.ListTimers(uint64(ctx.Event.GroupID))))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 随机点名
|
// 随机点名
|
||||||
@ -330,9 +330,9 @@ func init() { // 插件主体
|
|||||||
if ctx.Event.NoticeType == "group_increase" {
|
if ctx.Event.NoticeType == "group_increase" {
|
||||||
word, ok := config.Welcome[uint64(ctx.Event.GroupID)]
|
word, ok := config.Welcome[uint64(ctx.Event.GroupID)]
|
||||||
if ok {
|
if ok {
|
||||||
ctx.Send(word)
|
ctx.SendChain(message.Text(word))
|
||||||
} else {
|
} else {
|
||||||
ctx.Send("欢迎~")
|
ctx.SendChain(message.Text("欢迎~"))
|
||||||
}
|
}
|
||||||
enable, ok1 := config.Checkin[uint64(ctx.Event.GroupID)]
|
enable, ok1 := config.Checkin[uint64(ctx.Event.GroupID)]
|
||||||
if ok1 && enable {
|
if ok1 && enable {
|
||||||
@ -349,7 +349,7 @@ func init() { // 插件主体
|
|||||||
ans, err := strconv.Atoi(text)
|
ans, err := strconv.Atoi(text)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if ans != r {
|
if ans != r {
|
||||||
ctx.Send("答案不对哦,再想想吧~")
|
ctx.SendChain(message.Text("答案不对哦,再想想吧~"))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@ -362,12 +362,12 @@ func init() { // 插件主体
|
|||||||
recv, cancel := next.Repeat()
|
recv, cancel := next.Repeat()
|
||||||
select {
|
select {
|
||||||
case <-time.After(time.Minute):
|
case <-time.After(time.Minute):
|
||||||
ctx.Send("拜拜啦~")
|
ctx.SendChain(message.Text("拜拜啦~"))
|
||||||
ctx.SetGroupKick(ctx.Event.GroupID, uid, false)
|
ctx.SetGroupKick(ctx.Event.GroupID, uid, false)
|
||||||
cancel()
|
cancel()
|
||||||
case <-recv:
|
case <-recv:
|
||||||
cancel()
|
cancel()
|
||||||
ctx.Send("答对啦~")
|
ctx.SendChain(message.Text("答对啦~"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -384,9 +384,9 @@ func init() { // 插件主体
|
|||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
config.Welcome[uint64(ctx.Event.GroupID)] = ctx.State["regex_matched"].([]string)[1]
|
config.Welcome[uint64(ctx.Event.GroupID)] = ctx.State["regex_matched"].([]string)[1]
|
||||||
if saveConfig() == nil {
|
if saveConfig() == nil {
|
||||||
ctx.Send("记住啦!")
|
ctx.SendChain(message.Text("记住啦!"))
|
||||||
} else {
|
} else {
|
||||||
ctx.Send("出错啦!")
|
ctx.SendChain(message.Text("出错啦!"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 入群验证开关
|
// 入群验证开关
|
||||||
@ -402,9 +402,9 @@ func init() { // 插件主体
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if saveConfig() == nil {
|
if saveConfig() == nil {
|
||||||
ctx.Send("已" + option)
|
ctx.SendChain(message.Text("已", option))
|
||||||
} else {
|
} else {
|
||||||
ctx.Send("出错啦!")
|
ctx.SendChain(message.Text("出错啦!"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 运行 CQ 码
|
// 运行 CQ 码
|
||||||
@ -413,6 +413,7 @@ func init() { // 插件主体
|
|||||||
var cmd = ctx.State["regex_matched"].([]string)[1]
|
var cmd = ctx.State["regex_matched"].([]string)[1]
|
||||||
cmd = strings.ReplaceAll(cmd, "[", "[")
|
cmd = strings.ReplaceAll(cmd, "[", "[")
|
||||||
cmd = strings.ReplaceAll(cmd, "]", "]")
|
cmd = strings.ReplaceAll(cmd, "]", "]")
|
||||||
|
// 可注入,权限为主人
|
||||||
ctx.Send(cmd)
|
ctx.Send(cmd)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,7 @@ func init() {
|
|||||||
_ = ctx.Parse(&model)
|
_ = ctx.Parse(&model)
|
||||||
ctx.SendChain(message.Text("开启服务器: ", model.Args, "....."))
|
ctx.SendChain(message.Text("开启服务器: ", model.Args, "....."))
|
||||||
result := start(model.Args)
|
result := start(model.Args)
|
||||||
ctx.Send(result)
|
ctx.SendChain(message.Text(result))
|
||||||
})
|
})
|
||||||
engine.OnCommand("mcstop").SetBlock(true).
|
engine.OnCommand("mcstop").SetBlock(true).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
@ -43,7 +43,7 @@ func init() {
|
|||||||
_ = ctx.Parse(&model)
|
_ = ctx.Parse(&model)
|
||||||
ctx.SendChain(message.Text("开启服务器: ", model.Args, "....."))
|
ctx.SendChain(message.Text("开启服务器: ", model.Args, "....."))
|
||||||
result := stop(model.Args)
|
result := stop(model.Args)
|
||||||
ctx.Send(result)
|
ctx.SendChain(message.Text(result))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,7 @@ func init() {
|
|||||||
}).OnRegex("^(.{0,2})点歌(.{1,25})$").SetBlock(true).FirstPriority().
|
}).OnRegex("^(.{0,2})点歌(.{1,25})$").SetBlock(true).FirstPriority().
|
||||||
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.Send("请稍后重试0x0...")
|
ctx.SendChain(message.Text("请稍后重试0x0..."))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// switch 平台
|
// switch 平台
|
||||||
|
|||||||
@ -107,7 +107,7 @@ func init() {
|
|||||||
}).OnRegex(`^>runcode\s(.+?)\s([\s\S]+)$`).SetBlock(true).SecondPriority().
|
}).OnRegex(`^>runcode\s(.+?)\s([\s\S]+)$`).SetBlock(true).SecondPriority().
|
||||||
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.Send("请稍后重试0x0...")
|
ctx.SendChain(message.Text("请稍后重试0x0..."))
|
||||||
} else {
|
} else {
|
||||||
language := ctx.State["regex_matched"].([]string)[1]
|
language := ctx.State["regex_matched"].([]string)[1]
|
||||||
language = strings.ToLower(language)
|
language = strings.ToLower(language)
|
||||||
|
|||||||
@ -27,7 +27,7 @@ func init() { // 插件主体
|
|||||||
engine.OnRegex(`^搜图(\d+)$`).SetBlock(true).FirstPriority().
|
engine.OnRegex(`^搜图(\d+)$`).SetBlock(true).FirstPriority().
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
id, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[1], 10, 64)
|
id, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[1], 10, 64)
|
||||||
ctx.Send("少女祈祷中......")
|
ctx.SendChain(message.Text("少女祈祷中......"))
|
||||||
// 获取P站插图信息
|
// 获取P站插图信息
|
||||||
illust, err := pixiv.Works(id)
|
illust, err := pixiv.Works(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -51,14 +51,14 @@ func init() { // 插件主体
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
ctx.Send("图片不存在!")
|
ctx.SendChain(message.Text("图片不存在!"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 以图搜图
|
// 以图搜图
|
||||||
engine.OnKeywordGroup([]string{"以图搜图", "搜索图片", "以图识图"}, picture.CmdMatch, picture.MustGiven).SetBlock(true).FirstPriority().
|
engine.OnKeywordGroup([]string{"以图搜图", "搜索图片", "以图识图"}, picture.CmdMatch, picture.MustGiven).SetBlock(true).FirstPriority().
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
// 开始搜索图片
|
// 开始搜索图片
|
||||||
ctx.Send("少女祈祷中......")
|
ctx.SendChain(message.Text("少女祈祷中......"))
|
||||||
for _, pic := range ctx.State["image_url"].([]string) {
|
for _, pic := range ctx.State["image_url"].([]string) {
|
||||||
fmt.Println(pic)
|
fmt.Println(pic)
|
||||||
if result, err := saucenao.SauceNAO(pic); err != nil {
|
if result, err := saucenao.SauceNAO(pic); err != nil {
|
||||||
|
|||||||
@ -169,7 +169,7 @@ func init() { // 插件主体
|
|||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Send("添加成功")
|
ctx.SendChain(message.Text("添加成功"))
|
||||||
})
|
})
|
||||||
|
|
||||||
engine.OnRegex(`^删除(.*?)(\d+)$`, firstValueInList(pool.List), zero.SuperUserPermission).SetBlock(true).SetPriority(22).
|
engine.OnRegex(`^删除(.*?)(\d+)$`, firstValueInList(pool.List), zero.SuperUserPermission).SetBlock(true).SetPriority(22).
|
||||||
@ -180,10 +180,10 @@ func init() { // 插件主体
|
|||||||
)
|
)
|
||||||
// 查询数据库
|
// 查询数据库
|
||||||
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))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Send("删除成功")
|
ctx.SendChain(message.Text("删除成功"))
|
||||||
})
|
})
|
||||||
|
|
||||||
// 查询数据库涩图数量
|
// 查询数据库涩图数量
|
||||||
@ -200,7 +200,7 @@ func init() { // 插件主体
|
|||||||
state = append(state, ": ")
|
state = append(state, ": ")
|
||||||
state = append(state, fmt.Sprintf("%d", num))
|
state = append(state, fmt.Sprintf("%d", num))
|
||||||
}
|
}
|
||||||
ctx.Send(strings.Join(state, ""))
|
ctx.SendChain(message.Text(state))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* @Author: Kanri
|
||||||
|
* @Date: 2021-10-15 21:23:14
|
||||||
|
* @LastEditors: Kanri
|
||||||
|
* @LastEditTime: 2021-10-15 21:42:51
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
// Package shindan 基于 https://shindanmaker.com 的测定小功能
|
// Package shindan 基于 https://shindanmaker.com 的测定小功能
|
||||||
package shindan
|
package shindan
|
||||||
|
|
||||||
@ -52,6 +59,7 @@ func handle(ctx *zero.Ctx) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
}
|
}
|
||||||
|
// TODO: 可注入
|
||||||
ctx.Send(text)
|
ctx.Send(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DownloadTo 下载到路径
|
||||||
func DownloadTo(url, file string) error {
|
func DownloadTo(url, file string) error {
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// Package math 计算实用工具
|
// Package math 计算实用工具
|
||||||
package math
|
package math
|
||||||
|
|
||||||
// min 返回两数最大值,该函数将被内联
|
// Max 返回两数最大值,该函数将被内联
|
||||||
func Max(a, b int) int {
|
func Max(a, b int) int {
|
||||||
if a > b {
|
if a > b {
|
||||||
return a
|
return a
|
||||||
@ -9,7 +9,7 @@ func Max(a, b int) int {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
// min 返回两数最小值,该函数将被内联
|
// Min 返回两数最小值,该函数将被内联
|
||||||
func Min(a, b int) int {
|
func Min(a, b int) int {
|
||||||
if a > b {
|
if a > b {
|
||||||
return b
|
return b
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user