mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
✨ 应用插件控制到大部分插件
This commit is contained in:
parent
cb3cfa054b
commit
91396c8885
@ -66,8 +66,7 @@
|
|||||||
- [x] >github [xxx]
|
- [x] >github [xxx]
|
||||||
- [x] >github -p [xxx]
|
- [x] >github -p [xxx]
|
||||||
- **在线代码运行** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_runcode"`
|
- **在线代码运行** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_runcode"`
|
||||||
- [x] > runcode help
|
- [x] > runcode [language] help
|
||||||
- [x] > runcode [on/off]
|
|
||||||
- [x] > runcode [language] [code block]
|
- [x] > runcode [language] [code block]
|
||||||
- **点歌** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_music"`
|
- **点歌** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_music"`
|
||||||
- [x] 点歌[xxx]
|
- [x] 点歌[xxx]
|
||||||
@ -118,7 +117,9 @@
|
|||||||
- [ ] 简易语音
|
- [ ] 简易语音
|
||||||
- [ ] 爬图合成 [@xxx]
|
- [ ] 爬图合成 [@xxx]
|
||||||
- **minecraft** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft"`
|
- **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)项目对服务器的管理api,mc服务器如果没有在该管理平台部署此功能无效
|
- 注:此功能实现依赖[MCSManager](https://github.com/Suwings/MCSManager)项目对服务器的管理api,mc服务器如果没有在该管理平台部署此功能无效
|
||||||
- **炉石** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs"`
|
- **炉石** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs"`
|
||||||
- [x] 搜卡[xxxx]
|
- [x] 搜卡[xxxx]
|
||||||
@ -126,8 +127,6 @@
|
|||||||
- 注:更多搜卡指令参数:https://hs.fbigame.com/misc/searchhelp
|
- 注:更多搜卡指令参数:https://hs.fbigame.com/misc/searchhelp
|
||||||
- **青云客** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_qingyunke"`
|
- **青云客** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_qingyunke"`
|
||||||
- [x] @Bot 任意文本(任意一句话回复)
|
- [x] @Bot 任意文本(任意一句话回复)
|
||||||
- [x] 关闭自动回复
|
|
||||||
- [x] 启动自动回复
|
|
||||||
- **关键字搜图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_image_finder"`
|
- **关键字搜图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_image_finder"`
|
||||||
- [x] 来张 [xxx]
|
- [x] 来张 [xxx]
|
||||||
- **TODO...**
|
- **TODO...**
|
||||||
|
|||||||
@ -20,12 +20,11 @@ func init() { // 插件主体
|
|||||||
// TODO: 1.17 特性暂不增加
|
// TODO: 1.17 特性暂不增加
|
||||||
// rand.Seed(time.Now().UnixMicro())
|
// rand.Seed(time.Now().UnixMicro())
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
engine := control.Register("aiwife", &control.Options{
|
control.Register("aiwife", &control.Options{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
Help: "AIWife\n" +
|
Help: "AIWife\n" +
|
||||||
"- waifu|随机waifu",
|
"- waifu|随机waifu",
|
||||||
})
|
}).OnFullMatchGroup([]string{"waifu", "随机waifu"}).SetPriority(10).
|
||||||
engine.OnFullMatchGroup([]string{"waifu", "随机waifu"}).SetPriority(10).
|
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
miku := rand.Intn(100000) + 1
|
miku := rand.Intn(100000) + 1
|
||||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Image(fmt.Sprintf(bed, miku)))
|
ctx.SendChain(message.At(ctx.Event.UserID), message.Image(fmt.Sprintf(bed, miku)))
|
||||||
|
|||||||
@ -18,13 +18,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() { // 插件主体
|
func init() { // 插件主体
|
||||||
engine := control.Register("github", &control.Options{
|
control.Register("github", &control.Options{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
Help: "GitHub仓库搜索\n" +
|
Help: "GitHub仓库搜索\n" +
|
||||||
"- >github [xxx]\n" +
|
"- >github [xxx]\n" +
|
||||||
"- >github -p [xxx]",
|
"- >github -p [xxx]",
|
||||||
})
|
}).OnRegex(`^>github\s(-.{1,10}? )?(.*)$`).SetBlock(true).FirstPriority().
|
||||||
engine.OnRegex(`^>github\s(-.{1,10}? )?(.*)$`).SetBlock(true).FirstPriority().
|
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
// 发送请求
|
// 发送请求
|
||||||
header := http.Header{
|
header := http.Header{
|
||||||
|
|||||||
@ -61,12 +61,11 @@ type resultjson struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
engine := control.Register("imgfinder", &control.Options{
|
control.Register("imgfinder", &control.Options{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
Help: "关键字搜图\n" +
|
Help: "关键字搜图\n" +
|
||||||
"- 来张 [xxx]",
|
"- 来张 [xxx]",
|
||||||
})
|
}).OnRegex(`^来张 (.*)$`, zero.AdminPermission).
|
||||||
engine.OnRegex(`^来张 (.*)$`, zero.AdminPermission).
|
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
keyword := ctx.State["regex_matched"].([]string)[1]
|
keyword := ctx.State["regex_matched"].([]string)[1]
|
||||||
soutujson := soutuapi(keyword)
|
soutujson := soutuapi(keyword)
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
@ -21,7 +22,11 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
zero.OnFullMatch("来份萝莉").
|
control.Register("lolicon", &control.Options{
|
||||||
|
DisableOnDefault: false,
|
||||||
|
Help: "lolicon\n" +
|
||||||
|
"- 来份萝莉",
|
||||||
|
}).OnFullMatch("来份萝莉").
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
go func() {
|
go func() {
|
||||||
for i := 0; i < min(cap(queue)-len(queue), 2); i++ {
|
for i := 0; i < min(cap(queue)-len(queue), 2); i++ {
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
|
"github.com/wdvxdr1123/ZeroBot/extension"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -36,22 +37,21 @@ type resultjson struct {
|
|||||||
} `json:"players"`
|
} `json:"players"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
servers = make(map[string]string)
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
zero.OnRegex(`^/list (.*)$`).
|
// 这里填对应mc服务器的登录地址
|
||||||
|
servers["ftbi"] = "115.28.186.22:25710"
|
||||||
|
servers["ges"] = "115.28.186.22:25701"
|
||||||
|
|
||||||
|
engine.OnCommand("mclist").
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
model := extension.CommandModel{}
|
||||||
|
_ = ctx.Parse(&model)
|
||||||
// 支持多个服务器
|
// 支持多个服务器
|
||||||
switch ctx.State["regex_matched"].([]string)[1] {
|
gesjson := infoapi(servers[model.Args])
|
||||||
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
|
var str = gesjson.Players.List
|
||||||
cs := strings.Join(str, "\n")
|
cs := strings.Join(str, "\n")
|
||||||
ctx.SendChain(message.Text(
|
ctx.SendChain(message.Text(
|
||||||
@ -59,7 +59,6 @@ func init() {
|
|||||||
"在线人数: ", gesjson.Players.Online, "/", gesjson.Players.Max, "\n",
|
"在线人数: ", gesjson.Players.Online, "/", gesjson.Players.Max, "\n",
|
||||||
"以下为玩家名字: ", "\n", cs,
|
"以下为玩家名字: ", "\n", cs,
|
||||||
))
|
))
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,9 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
|
"github.com/wdvxdr1123/ZeroBot/extension"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,29 +16,40 @@ import (
|
|||||||
// 项目地址: https://github.com/Suwings/MCSManager
|
// 项目地址: https://github.com/Suwings/MCSManager
|
||||||
// 项目的api文档: https://github.com/Suwings/MCSManager/wiki/API-Documentation
|
// 项目的api文档: https://github.com/Suwings/MCSManager/wiki/API-Documentation
|
||||||
|
|
||||||
func init() {
|
const api = "http://your.addr:23333/api/start_server/%s/?apikey=apikey"
|
||||||
zero.OnRegex(`^/start (.*)$`).
|
|
||||||
Handle(func(ctx *zero.Ctx) {
|
var engine *zero.Engine
|
||||||
name := ctx.State["regex_matched"].([]string)[1]
|
|
||||||
ctx.SendChain(message.Text("开启服务器: ", name, "....."))
|
|
||||||
result := start(name)
|
|
||||||
ctx.Send(result)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
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").
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
name := ctx.State["regex_matched"].([]string)[1]
|
model := extension.CommandModel{}
|
||||||
ctx.SendChain(message.Text("关闭服务器: ", name, "....."))
|
_ = ctx.Parse(&model)
|
||||||
result := stop(name)
|
ctx.SendChain(message.Text("开启服务器: ", model.Args, "....."))
|
||||||
|
result := start(model.Args)
|
||||||
|
ctx.Send(result)
|
||||||
|
})
|
||||||
|
engine.OnCommand("mcstop").
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
model := extension.CommandModel{}
|
||||||
|
_ = ctx.Parse(&model)
|
||||||
|
ctx.SendChain(message.Text("开启服务器: ", model.Args, "....."))
|
||||||
|
result := stop(model.Args)
|
||||||
ctx.Send(result)
|
ctx.Send(result)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 开启服务器的api请求
|
// 开启服务器的api请求
|
||||||
func start(name string) string {
|
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{}
|
client := &http.Client{}
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -57,7 +70,7 @@ func start(name string) string {
|
|||||||
|
|
||||||
// 关闭服务器的api请求
|
// 关闭服务器的api请求
|
||||||
func stop(name string) string {
|
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{}
|
client := &http.Client{}
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||||
@ -20,7 +21,14 @@ import (
|
|||||||
var limit = rate.NewManager(time.Minute*3, 5)
|
var limit = rate.NewManager(time.Minute*3, 5)
|
||||||
|
|
||||||
func init() {
|
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) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.UserID).Acquire() {
|
if !limit.Load(ctx.Event.UserID).Acquire() {
|
||||||
ctx.Send("请稍后重试0x0...")
|
ctx.Send("请稍后重试0x0...")
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
)
|
)
|
||||||
@ -18,7 +19,11 @@ func init() { // 插件主体
|
|||||||
// TODO: 1.17 特性暂不增加
|
// TODO: 1.17 特性暂不增加
|
||||||
// rand.Seed(time.Now().UnixMicro())
|
// rand.Seed(time.Now().UnixMicro())
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
zero.OnFullMatchGroup([]string{"求签", "运势", "占卜"}).SetPriority(10).
|
control.Register("omikuji", &control.Options{
|
||||||
|
DisableOnDefault: false,
|
||||||
|
Help: "浅草寺求签\n" +
|
||||||
|
"- 求签|运势|占卜",
|
||||||
|
}).OnFullMatchGroup([]string{"求签", "运势", "占卜"}).SetPriority(10).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
miku := rand.Intn(100) + 1
|
miku := rand.Intn(100) + 1
|
||||||
ctx.SendChain(
|
ctx.SendChain(
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
@ -22,23 +23,17 @@ import (
|
|||||||
var (
|
var (
|
||||||
prio = 3
|
prio = 3
|
||||||
bucket = rate.NewManager(time.Minute, 20) // 青云客接口回复
|
bucket = rate.NewManager(time.Minute, 20) // 青云客接口回复
|
||||||
enable = true
|
engine *zero.Engine
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { // 插件主体
|
func init() { // 插件主体
|
||||||
// 开关
|
engine = control.Register("qingyunke", &control.Options{
|
||||||
zero.OnFullMatch("开启自动回复", zero.SuperUserPermission).SetBlock(true).SetPriority(prio).
|
DisableOnDefault: false,
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Help: "青云客\n" +
|
||||||
enable = true
|
"- @Bot 任意文本(任意一句话回复)",
|
||||||
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.OnRegex("(^.{1,30}$)", zero.OnlyToMe).SetBlock(true).SetPriority(prio).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if !bucket.Load(ctx.Event.UserID).Acquire() {
|
if !bucket.Load(ctx.Event.UserID).Acquire() {
|
||||||
// 频繁触发,不回复
|
// 频繁触发,不回复
|
||||||
@ -152,9 +147,3 @@ func getAgent() string {
|
|||||||
len1 := len(agent)
|
len1 := len(agent)
|
||||||
return agent[r.Intn(len1)]
|
return agent[r.Intn(len1)]
|
||||||
}
|
}
|
||||||
|
|
||||||
func switchQYK() zero.Rule {
|
|
||||||
return func(ctx *zero.Ctx) bool {
|
|
||||||
return enable
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
@ -17,7 +18,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
enable = true
|
|
||||||
limit = rate.NewManager(time.Minute*3, 5)
|
limit = rate.NewManager(time.Minute*3, 5)
|
||||||
templates = map[string]string{
|
templates = map[string]string{
|
||||||
"py2": "print 'Hello World!'",
|
"py2": "print 'Hello World!'",
|
||||||
@ -92,40 +92,18 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
zero.OnFullMatch(">runcode help").SetBlock(true).FirstPriority().
|
control.Register("runcode", &control.Options{
|
||||||
Handle(func(ctx *zero.Ctx) {
|
DisableOnDefault: false,
|
||||||
ctx.SendChain(message.Text(
|
Help: "在线代码运行: \n" +
|
||||||
"使用说明: ", "\n",
|
">runcode [language] [code block]\n" +
|
||||||
">runcode [language] [code block]", "\n",
|
"模板查看: \n" +
|
||||||
"模板查看: ", "\n",
|
">runcode [language] help\n" +
|
||||||
">runcode [language] help", "\n",
|
"支持语种: \n" +
|
||||||
"支持语种: ", "\n",
|
"Go || Python || C/C++ || C# || Java || Lua \n" +
|
||||||
"Go || Python || C/C++ || C# || Java || Lua ", "\n",
|
"JavaScript || TypeScript || PHP || Shell \n" +
|
||||||
"JavaScript || TypeScript || PHP || Shell ", "\n",
|
"Kotlin || Rust || Erlang || Ruby || Swift \n" +
|
||||||
"Kotlin || Rust || Erlang || Ruby || Swift ", "\n",
|
"R || VB || Py2 || Perl || Pascal || Scala",
|
||||||
"R || VB || Py2 || Perl || Pascal || Scala ", "\n",
|
}).OnRegex(`^>runcode\s(.+?)\s([\s\S]+)$`).SetBlock(true).SecondPriority().
|
||||||
))
|
|
||||||
})
|
|
||||||
|
|
||||||
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().
|
|
||||||
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.Send("请稍后重试0x0...")
|
||||||
@ -138,13 +116,6 @@ func init() {
|
|||||||
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
|
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
|
||||||
message.Text("语言不是受支持的编程语种呢~"),
|
message.Text("语言不是受支持的编程语种呢~"),
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
if !enable {
|
|
||||||
// 运行代码被禁用
|
|
||||||
ctx.SendChain(
|
|
||||||
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
|
|
||||||
message.Text("在线运行代码功能已被禁用"),
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
// 执行运行
|
// 执行运行
|
||||||
block := ctx.State["regex_matched"].([]string)[2]
|
block := ctx.State["regex_matched"].([]string)[2]
|
||||||
@ -175,7 +146,6 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,11 +13,18 @@ import (
|
|||||||
"github.com/FloatTech/AnimeAPI/picture"
|
"github.com/FloatTech/AnimeAPI/picture"
|
||||||
"github.com/FloatTech/AnimeAPI/pixiv"
|
"github.com/FloatTech/AnimeAPI/pixiv"
|
||||||
"github.com/FloatTech/AnimeAPI/saucenao"
|
"github.com/FloatTech/AnimeAPI/saucenao"
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { // 插件主体
|
func init() { // 插件主体
|
||||||
|
engine := control.Register("saucenao", &control.Options{
|
||||||
|
DisableOnDefault: false,
|
||||||
|
Help: "搜图\n" +
|
||||||
|
"- 以图搜图|搜索图片|以图识图[图片]\n" +
|
||||||
|
"- 搜图[P站图片ID]",
|
||||||
|
})
|
||||||
// 根据 PID 搜图
|
// 根据 PID 搜图
|
||||||
zero.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.Send("少女祈祷中......")
|
||||||
@ -48,7 +55,7 @@ func init() { // 插件主体
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 以图搜图
|
// 以图搜图
|
||||||
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) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
// 开始搜索图片
|
// 开始搜索图片
|
||||||
ctx.Send("少女祈祷中......")
|
ctx.Send("少女祈祷中......")
|
||||||
|
|||||||
@ -12,12 +12,12 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/FloatTech/AnimeAPI/pixiv"
|
"github.com/FloatTech/AnimeAPI/pixiv"
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||||
|
. "github.com/FloatTech/ZeroBot-Plugin/data"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
|
|
||||||
. "github.com/FloatTech/ZeroBot-Plugin/data"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Pools 图片缓冲池
|
// Pools 图片缓冲池
|
||||||
@ -86,7 +86,15 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() { // 插件主体
|
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) {
|
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..."))
|
||||||
@ -130,7 +138,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) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
var (
|
var (
|
||||||
imgtype = ctx.State["regex_matched"].([]string)[1]
|
imgtype = ctx.State["regex_matched"].([]string)[1]
|
||||||
@ -161,7 +169,7 @@ func init() { // 插件主体
|
|||||||
ctx.Send("添加成功")
|
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) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
var (
|
var (
|
||||||
imgtype = ctx.State["regex_matched"].([]string)[1]
|
imgtype = ctx.State["regex_matched"].([]string)[1]
|
||||||
@ -176,7 +184,7 @@ 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) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
state := []string{"[SetuTime]"}
|
state := []string{"[SetuTime]"}
|
||||||
for i := range pool.List {
|
for i := range pool.List {
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/FloatTech/AnimeAPI/shindanmaker"
|
"github.com/FloatTech/AnimeAPI/shindanmaker"
|
||||||
|
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
@ -17,10 +18,18 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
zero.OnPrefix("异世界转生", number(587874)).SetBlock(true).FirstPriority().Handle(handle)
|
engine := control.Register("shindan", &control.Options{
|
||||||
zero.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).FirstPriority().Handle(handle)
|
DisableOnDefault: false,
|
||||||
zero.OnPrefix("卖萌", number(360578)).SetBlock(true).FirstPriority().Handle(handle)
|
Help: "shindan\n" +
|
||||||
zero.OnPrefix("抽老婆", number(1075116)).SetBlock(true).FirstPriority().Handle(handle)
|
"- 今天是什么少女[@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 处理函数
|
// shindanmaker 处理函数
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user