mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
commands: ignore notices
This commit is contained in:
parent
06a292e1cc
commit
db62b9a1d8
2 changed files with 7 additions and 1 deletions
|
|
@ -58,10 +58,16 @@ var IDHTMLParser = &format.HTMLParser{
|
|||
// ParseEvent parses a message into a command event struct.
|
||||
func ParseEvent[MetaType any](ctx context.Context, evt *event.Event) *Event[MetaType] {
|
||||
content := evt.Content.Parsed.(*event.MessageEventContent)
|
||||
if content.MsgType == event.MsgNotice || content.RelatesTo.GetReplaceID() != "" {
|
||||
return nil
|
||||
}
|
||||
text := content.Body
|
||||
if content.Format == event.FormatHTML {
|
||||
text = IDHTMLParser.Parse(content.FormattedBody, format.NewContext(ctx))
|
||||
}
|
||||
if len(text) == 0 {
|
||||
return nil
|
||||
}
|
||||
parts := strings.Fields(text)
|
||||
return &Event[MetaType]{
|
||||
Event: evt,
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func (proc *Processor[MetaType]) Process(ctx context.Context, evt *event.Event)
|
|||
}
|
||||
}()
|
||||
parsed := ParseEvent[MetaType](ctx, evt)
|
||||
if !proc.PreValidator.Validate(parsed) {
|
||||
if parsed == nil || !proc.PreValidator.Validate(parsed) {
|
||||
return
|
||||
}
|
||||
parsed.Proc = proc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue