commands/event: allow overriding mentions when replying
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 19:59:31 +03:00
commit e0b1e9b0d3

View file

@ -81,12 +81,13 @@ func ParseEvent[MetaType any](ctx context.Context, evt *event.Event) *Event[Meta
}
type ReplyOpts struct {
AllowHTML bool
AllowMarkdown bool
Reply bool
Thread bool
SendAsText bool
Edit id.EventID
AllowHTML bool
AllowMarkdown bool
Reply bool
Thread bool
SendAsText bool
Edit id.EventID
OverrideMentions *event.Mentions
}
func (evt *Event[MetaType]) Reply(msg string, args ...any) id.EventID {
@ -110,6 +111,9 @@ func (evt *Event[MetaType]) Respond(msg string, opts ReplyOpts) id.EventID {
if opts.Edit != "" {
content.SetEdit(opts.Edit)
}
if opts.OverrideMentions != nil {
content.Mentions = opts.OverrideMentions
}
resp, err := evt.Proc.Client.SendMessageEvent(evt.Ctx, evt.RoomID, event.EventMessage, content)
if err != nil {
zerolog.Ctx(evt.Ctx).Err(err).Msg("Failed to send reply")