mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
✏️ nwife 防注入
This commit is contained in:
parent
1d9813691c
commit
b20cb1c0a0
@ -60,7 +60,7 @@ type request struct {
|
|||||||
// InitGui 初始化gui
|
// InitGui 初始化gui
|
||||||
func InitGui(addr string) {
|
func InitGui(addr string) {
|
||||||
// 将日志重定向到前端hook
|
// 将日志重定向到前端hook
|
||||||
writer := io.MultiWriter(l, os.Stderr)
|
writer := io.MultiWriter(l, os.Stdout)
|
||||||
log.SetOutput(writer)
|
log.SetOutput(writer)
|
||||||
// 监听后端
|
// 监听后端
|
||||||
go controller(addr)
|
go controller(addr)
|
||||||
|
|||||||
13
main.go
13
main.go
@ -80,8 +80,8 @@ func init() {
|
|||||||
d := flag.Bool("d", false, "Enable debug level log and higher.")
|
d := flag.Bool("d", false, "Enable debug level log and higher.")
|
||||||
w := flag.Bool("w", false, "Enable warning level log and higher.")
|
w := flag.Bool("w", false, "Enable warning level log and higher.")
|
||||||
h := flag.Bool("h", false, "Display this help.")
|
h := flag.Bool("h", false, "Display this help.")
|
||||||
// 解析命令行参数,输入 `-g 监听地址:端口` 即可启用 gui
|
// 解析命令行参数,输入 `-g 监听地址:端口` 指定 gui 访问地址,默认 127.0.0.1:3000
|
||||||
// g := flag.String("g", "127.0.0.1:3000", "Enable web gui.")
|
// g := flag.String("g", "127.0.0.1:3000", "Set web gui listening address.")
|
||||||
|
|
||||||
// 直接写死 AccessToken 时,请更改下面第二个参数
|
// 直接写死 AccessToken 时,请更改下面第二个参数
|
||||||
token = flag.String("t", "", "Set AccessToken of WSClient.")
|
token = flag.String("t", "", "Set AccessToken of WSClient.")
|
||||||
@ -102,10 +102,8 @@ func init() {
|
|||||||
logrus.SetLevel(logrus.WarnLevel)
|
logrus.SetLevel(logrus.WarnLevel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 解析命令行参数,输入 `-g` 即可启用 gui
|
// 启用 gui
|
||||||
// if *g {
|
// webctrl.InitGui(*g)
|
||||||
// webctrl.InitGui(*g)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func printBanner() {
|
func printBanner() {
|
||||||
@ -121,8 +119,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.SendChain(message.Text("可发送\"/服务详情\"等指令,查看bot功能"))
|
ctx.SendChain(message.Text(banner, "\n可发送\"/服务详情\"查看 bot 功能"))
|
||||||
ctx.SendChain(message.Text(banner))
|
|
||||||
})
|
})
|
||||||
zero.RunAndBlock(
|
zero.RunAndBlock(
|
||||||
zero.Config{
|
zero.Config{
|
||||||
|
|||||||
@ -33,7 +33,7 @@ func init() {
|
|||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
Help: "nativewife\n- 抽wife[@xxx]\n- 添加wife[名字][图片]\n- 删除wife[名字]\n- [让|不让]所有人均可添加wife",
|
Help: "nativewife\n- 抽wife[@xxx]\n- 添加wife[名字][图片]\n- 删除wife[名字]\n- [让|不让]所有人均可添加wife",
|
||||||
})
|
})
|
||||||
engine.OnPrefix("抽wife", zero.OnlyGroup).SetBlock(true).SetPriority(20).
|
engine.OnFullMatch("抽wife", zero.OnlyGroup).SetBlock(true).SetPriority(20).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
grpf := strconv.FormatInt(ctx.Event.GroupID, 36)
|
grpf := strconv.FormatInt(ctx.Event.GroupID, 36)
|
||||||
wifes, err := os.ReadDir(base + "/" + grpf)
|
wifes, err := os.ReadDir(base + "/" + grpf)
|
||||||
@ -72,6 +72,8 @@ func init() {
|
|||||||
if elem.Type == "text" {
|
if elem.Type == "text" {
|
||||||
name = strings.ReplaceAll(elem.Data["text"], " ", "")
|
name = strings.ReplaceAll(elem.Data["text"], " ", "")
|
||||||
name = name[strings.LastIndex(name, "添加wife")+10:]
|
name = name[strings.LastIndex(name, "添加wife")+10:]
|
||||||
|
name = strings.ReplaceAll(name, "/", "")
|
||||||
|
name = strings.ReplaceAll(name, "\\", "")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,6 +100,8 @@ func init() {
|
|||||||
if elem.Type == "text" {
|
if elem.Type == "text" {
|
||||||
name = strings.ReplaceAll(elem.Data["text"], " ", "")
|
name = strings.ReplaceAll(elem.Data["text"], " ", "")
|
||||||
name = name[strings.LastIndex(name, "删除wife")+10:]
|
name = name[strings.LastIndex(name, "删除wife")+10:]
|
||||||
|
name = strings.ReplaceAll(name, "/", "")
|
||||||
|
name = strings.ReplaceAll(name, "\\", "")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user