diff --git a/bot/command.go b/bot/command.go index 66ffeba..766c859 100644 --- a/bot/command.go +++ b/bot/command.go @@ -68,7 +68,7 @@ func (b *Bot) initCommands() commandList { description: "Send email", allowed: b.allowSend, }, - {allowed: b.allowOwner}, // delimiter + {allowed: b.allowOwner, description: "mailbox ownership"}, // delimiter // options commands { key: roomOptionMailbox, @@ -93,7 +93,7 @@ func (b *Bot) initCommands() commandList { description: "Get or set SMTP password of the room's mailbox", allowed: b.allowOwner, }, - {allowed: b.allowOwner}, // delimiter + {allowed: b.allowOwner, description: "mailbox options"}, // delimiter { key: roomOptionNoSend, description: fmt.Sprintf( @@ -166,7 +166,7 @@ func (b *Bot) initCommands() commandList { sanitizer: utils.SanitizeBoolString, allowed: b.allowOwner, }, - {allowed: b.allowOwner}, // delimiter + {allowed: b.allowOwner, description: "mailbox antispam"}, // delimiter { key: roomOptionSpamcheckMX, description: "only accept email from servers which seem prepared to receive it (those having valid MX records) (`true` - enable, `false` - disable)", @@ -188,7 +188,7 @@ func (b *Bot) initCommands() commandList { sanitizer: utils.SanitizeStringSlice, allowed: b.allowOwner, }, - {allowed: b.allowAdmin}, // delimiter + {allowed: b.allowAdmin, description: "server options"}, // delimiter { key: botOptionAdminRoom, description: "Get or set admin room", @@ -231,7 +231,7 @@ func (b *Bot) initCommands() commandList { description: "Delete specific mailbox", allowed: b.allowAdmin, }, - {allowed: b.allowAdmin}, // delimiter + {allowed: b.allowAdmin, description: "server antispam"}, // delimiter { key: botOptionGreylist, description: "Set automatic greylisting duration in minutes (0 - disabled)", @@ -361,7 +361,10 @@ func (b *Bot) sendHelp(ctx context.Context) { continue } if cmd.key == "" { - msg.WriteString("\n---\n") + msg.WriteString("\n---\n\n") + msg.WriteString("#### ") + msg.WriteString(cmd.description) + msg.WriteString("\n") continue } msg.WriteString("* **`") diff --git a/bot/message.go b/bot/message.go index 307fb39..1211dd4 100644 --- a/bot/message.go +++ b/bot/message.go @@ -3,6 +3,8 @@ package bot import ( "context" "strings" + + "gitlab.com/etke.cc/postmoogle/utils" ) func (b *Bot) handle(ctx context.Context) { @@ -20,7 +22,7 @@ func (b *Bot) handle(ctx context.Context) { message := strings.TrimSpace(content.Body) cmd := b.parseCommand(message, true) if cmd == nil { - if content.RelatesTo != nil { + if utils.EventParent("", content) != "" { b.SendEmailReply(ctx) } return diff --git a/utils/matrix.go b/utils/matrix.go index a836213..5723b8d 100644 --- a/utils/matrix.go +++ b/utils/matrix.go @@ -32,16 +32,17 @@ func EventParent(currentID id.EventID, content *event.MessageEventContent) id.Ev return currentID } - if content.GetRelatesTo() == nil { + relation := content.OptionalGetRelatesTo() + if relation == nil { return currentID } - threadParent := content.RelatesTo.GetThreadParent() + threadParent := relation.GetThreadParent() if threadParent != "" { return threadParent } - replyParent := content.RelatesTo.GetReplyTo() + replyParent := relation.GetReplyTo() if replyParent != "" { return replyParent }