mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-03-01 02:20:25 +00:00
模块化消息扩展、增加简易随机图片
This commit is contained in:
29
randimg/setu_geter.go
Normal file
29
randimg/setu_geter.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package randimg
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/Yiwen-Chan/ZeroBot-Plugin/msgext"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
)
|
||||
|
||||
var RANDOM_API_URL = "https://api.pixivweb.com/anime18r.php?return=img"
|
||||
|
||||
func init() { // 插件主体
|
||||
zero.OnRegex(`^设置随机图片网址(.*)$`, zero.SuperUserPermission).SetBlock(true).SetPriority(20).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
url := ctx.State["regex_matched"].([]string)[1]
|
||||
if !strings.HasPrefix(url, "http") {
|
||||
ctx.Send("URL非法!")
|
||||
} else {
|
||||
RANDOM_API_URL = url
|
||||
}
|
||||
return
|
||||
})
|
||||
// 随机图片
|
||||
zero.OnFullMatchGroup([]string{"随机图片"}).SetBlock(true).SetPriority(24).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.Send(msgext.ImageNoCache(RANDOM_API_URL))
|
||||
return
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user