mirror of
https://github.com/fumiama/NanoBot.git
synced 2026-06-08 20:20:23 +08:00
优化API报错消息 & onlyprivate
This commit is contained in:
18
rules.go
18
rules.go
@@ -289,18 +289,24 @@ func CheckGuild(guildID ...string) Rule {
|
||||
|
||||
// OnlyPrivate requires that the ctx.Event is direct message
|
||||
func OnlyPrivate(ctx *Ctx) bool {
|
||||
if ctx.Type == "" { // 确保无空
|
||||
return false
|
||||
if ctx.Message != nil {
|
||||
return ctx.Message.SrcGuildID != ""
|
||||
}
|
||||
return strings.HasPrefix(ctx.Type, "Direct")
|
||||
if ctx.Type != "" {
|
||||
return strings.HasPrefix(ctx.Type, "Direct")
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// OnlyPublic requires that the ctx.Event is channel message
|
||||
func OnlyPublic(ctx *Ctx) bool {
|
||||
if ctx.Type == "" { // 确保无空
|
||||
return false
|
||||
if ctx.Message != nil {
|
||||
return ctx.Message.SrcGuildID == ""
|
||||
}
|
||||
return !strings.HasPrefix(ctx.Type, "Direct")
|
||||
if ctx.Type != "" {
|
||||
return !strings.HasPrefix(ctx.Type, "Direct")
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// OnlyChannel requires that the ctx.Event is channel message
|
||||
|
||||
Reference in New Issue
Block a user