1
0
mirror of https://github.com/fumiama/NanoBot.git synced 2026-06-11 05:30:24 +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
func OnlyPrivate(ctx *Ctx) bool {
// OnlyDirect requires that the ctx.Event is direct message
func OnlyDirect(ctx *Ctx) bool {
if ctx.Message != nil {
return ctx.Message.SrcGuildID != ""
}
@@ -298,20 +298,20 @@ func OnlyPrivate(ctx *Ctx) bool {
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 {
if ctx.Message != nil {
return ctx.Message.SrcGuildID == ""
if ctx.Message != nil && ctx.Message.SrcGuildID != "" {
return false
}
if ctx.Type != "" {
return !strings.HasPrefix(ctx.Type, "Direct")
return strings.HasPrefix(ctx.Type, "At") || strings.HasPrefix(ctx.Type, "Public")
}
return false
}
// OnlyChannel requires that the ctx.Event is channel message
func OnlyChannel(ctx *Ctx) bool {
return OnlyPublic(ctx)
// OnlyPrivate requires that the ctx.Event is not public message
func OnlyPrivate(ctx *Ctx) bool {
return !OnlyPublic(ctx)
}
// SuperUserPermission only triggered by the bot's owner