diff --git a/event.go b/event.go index 03a890a..58ac060 100644 --- a/event.go +++ b/event.go @@ -74,7 +74,6 @@ func (bot *Bot) processEvent(payload *WebsocketPayload) { switch tp { case "Message": ctx.Message = (*Message)(x.UnsafePointer()) - ctx.Message.Content = MessageUnescape(ctx.Message.Content) log.Infoln(getLogHeader(), "收到 Guild:", ctx.Message.GuildID, ", Channel:", ctx.Message.ChannelID, "消息", ctx.Message.Author.ID, ":", ctx.Message.Content) } go match(ctx, matchers) diff --git a/rules.go b/rules.go index 7a2f9db..09bf0df 100644 --- a/rules.go +++ b/rules.go @@ -25,7 +25,7 @@ func PrefixGroupRule(prefixes ...string) Rule { return false } for _, prefix := range prefixes { - if strings.HasPrefix(msg.Content, prefix) { + if strings.HasPrefix(msg.Content, MessageEscape(prefix)) { ctx.State["prefix"] = prefix arg := strings.TrimLeft(msg.Content[len(prefix):], " ") ctx.State["args"] = arg @@ -57,7 +57,7 @@ func SuffixGroupRule(suffixes ...string) Rule { return false } for _, suffix := range suffixes { - if strings.HasSuffix(msg.Content, suffix) { + if strings.HasSuffix(msg.Content, MessageEscape(suffix)) { ctx.State["suffix"] = suffix arg := strings.TrimRight(msg.Content[:len(msg.Content)-len(suffix)], " ") ctx.State["args"] = arg @@ -102,7 +102,7 @@ func CommandGroupRule(commands ...string) Rule { return false } for _, command := range commands { - if strings.HasPrefix(cmdMessage, command) { + if strings.HasPrefix(cmdMessage, MessageEscape(command)) { ctx.State["command"] = command ctx.State["args"] = args return true @@ -158,7 +158,7 @@ func KeywordGroupRule(src ...string) Rule { return false } for _, str := range src { - if strings.Contains(msg.Content, str) { + if strings.Contains(msg.Content, MessageEscape(str)) { ctx.State["keyword"] = str return true } @@ -184,7 +184,7 @@ func FullMatchGroupRule(src ...string) Rule { return false } for _, str := range src { - if str == msg.Content { + if MessageEscape(str) == msg.Content { ctx.State["matched"] = msg.Content return true } @@ -442,7 +442,7 @@ func MustProvidePhoto(onmessage string, needphohint, failhint string) Rule { } return false case newCtx := <-next: - ctx.State["photos"] = newCtx.State["photos"] + ctx.State["attachments"] = newCtx.State["attachments"] ctx.Event = newCtx.Event return true }