Skip to content

Commit

Permalink
优化插件逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
lianhong2758 committed Nov 20, 2024
1 parent a50e874 commit cd60747
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions plugins/onplugin/on&off.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var en = rosm.Register(&rosm.PluginData{
})

func init() {
en.OnRex(`^/启用\s*(.*)`).Handle(func(ctx *rosm.Ctx) {
en.OnRex(`^/启用\s*(.*)`).SetRule(rosm.NoAtForOther()).Handle(func(ctx *rosm.Ctx) {
name := ctx.Being.ResultWord[1]
if _, ok := rosm.GetPlugins()[name]; !ok {
ctx.Send(message.Text("未找到插件: ", name))
Expand All @@ -32,7 +32,7 @@ func init() {
}
ctx.Send(message.Text(name, "已启用..."))
})
en.OnRex(`^/禁用\s*(.*)`).Handle(func(ctx *rosm.Ctx) {
en.OnRex(`^/禁用\s*(.*)`).SetRule(rosm.NoAtForOther()).Handle(func(ctx *rosm.Ctx) {
name := ctx.Being.ResultWord[1]
if _, ok := rosm.GetPlugins()[name]; !ok {
ctx.Send(message.Text("未找到插件: ", name))
Expand All @@ -45,7 +45,7 @@ func init() {
}
ctx.Send(message.Text(name, "已禁用..."))
})
en.OnRex(`^/用法\s*(.*)`).Handle(func(ctx *rosm.Ctx) {
en.OnRex(`^/用法\s*(.*)`).SetRule(rosm.NoAtForOther()).Handle(func(ctx *rosm.Ctx) {
name := ctx.Being.ResultWord[1]
plugin, ok := rosm.GetPlugins()[name]
if !ok {
Expand All @@ -67,7 +67,7 @@ func init() {
msg.WriteString(strings.Repeat("*", 20))
ctx.Send(message.Text(msg.String()))
})
en.OnWord(`早安`).SetRule(rosm.OnlyAtMe()).Handle(func(ctx *rosm.Ctx) {
en.OnWord(`早安`).SetRule(rosm.OnlyMaster()).Handle(func(ctx *rosm.Ctx) {
on := rosm.PluginIsOn(rosm.GetBoten())(ctx)
if !on {
err := rosm.PluginDB.InsertOff(rosm.GetBoten().Name, tool.MergePadString(ctx.Being.GroupID, ctx.Being.GuildID), false)
Expand All @@ -81,7 +81,7 @@ func init() {
ctx.Send(message.Text("早安,", rosm.GetRandBotName(), "已经在认真工作了喵~"))
}
})
en.OnWord(`晚安`).SetRule(rosm.OnlyAtMe()).Handle(func(ctx *rosm.Ctx) {
en.OnWord(`晚安`).SetRule(rosm.OnlyMaster()).Handle(func(ctx *rosm.Ctx) {
on := rosm.PluginIsOn(rosm.GetBoten())(ctx)
if on {
err := rosm.PluginDB.InsertOff(rosm.GetBoten().Name, tool.MergePadString(ctx.Being.GroupID, ctx.Being.GuildID), true)
Expand Down
2 changes: 1 addition & 1 deletion plugins/test/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func init() {
Name: "帮助菜单",
Help: "- /help\n",
})
en.OnWord("/help", "/帮助").Handle(func(ctx *rosm.Ctx) {
en.OnWord("/help", "/帮助").SetRule(rosm.OnlyAtMe()).Handle(func(ctx *rosm.Ctx) {
var msg strings.Builder
msg.WriteString("****RosmBot菜单*****")
for _, v := range rosm.GetPlugins() {
Expand Down

0 comments on commit cd60747

Please sign in to comment.