1
0
mirror of https://github.com/fumiama/NanoBot.git synced 2026-06-22 20:20:43 +08:00

fix: only ruls

This commit is contained in:
源文雨
2023-10-18 15:31:13 +09:00
parent 4c6486219e
commit 476766dc44

View File

@@ -287,8 +287,8 @@ func CheckGuild(guildID ...string) Rule {
} }
} }
// OnlyPrivate requires that the ctx.Event is direct message // OnlyDirect requires that the ctx.Event is direct message
func OnlyPrivate(ctx *Ctx) bool { func OnlyDirect(ctx *Ctx) bool {
if ctx.Message != nil { if ctx.Message != nil {
return ctx.Message.SrcGuildID != "" return ctx.Message.SrcGuildID != ""
} }
@@ -298,20 +298,20 @@ func OnlyPrivate(ctx *Ctx) bool {
return false return false
} }
// OnlyPublic requires that the ctx.Event is channel message // OnlyPublic requires that the ctx.Event is public message
func OnlyPublic(ctx *Ctx) bool { func OnlyPublic(ctx *Ctx) bool {
if ctx.Message != nil { if ctx.Message != nil && ctx.Message.SrcGuildID != "" {
return ctx.Message.SrcGuildID == "" return false
} }
if ctx.Type != "" { if ctx.Type != "" {
return !strings.HasPrefix(ctx.Type, "Direct") return strings.HasPrefix(ctx.Type, "At") || strings.HasPrefix(ctx.Type, "Public")
} }
return false return false
} }
// OnlyChannel requires that the ctx.Event is channel message // OnlyPrivate requires that the ctx.Event is not public message
func OnlyChannel(ctx *Ctx) bool { func OnlyPrivate(ctx *Ctx) bool {
return OnlyPublic(ctx) return !OnlyPublic(ctx)
} }
// SuperUserPermission only triggered by the bot's owner // SuperUserPermission only triggered by the bot's owner