commands: ignore notices
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run

This commit is contained in:
Tulir Asokan 2025-04-29 02:26:50 +03:00
commit db62b9a1d8
2 changed files with 7 additions and 1 deletions

View file

@ -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,

View file

@ -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