Improve sendHelp() to show full commands
It previously said "the following commands" were supported and it was only listing subcommands (help, stop, ..) without any indication of how the user should construct the full command (`PREFIX SUB_COMMAND`). For perfect clarity, we now list full commands in the help message. Example: > The following commands are supported: > > - !pm help - Show this help message > - !pm stop - Disable bridge for the room and clear all configuration > - !pm mailbox - Get or set mailbox of the room > - !pm owner - Get or set owner of the room > - !pm nosender - Get or set nosender of the room (true - hide email sender; false - show email sender) > - !pm nosubject - Get or set nosubject of the room (true - hide email subject; false - show email subject) The new help message is prefix-aware, instead of hardcodign `!pm`. If the bot is running with a custom prefix (not `!pm`), this is even more helpful, as it lets people know what the prefix is. Reading documentation elsewhere and seeing `!pm STUFF` will no longer confuse anyone. With this change, we also make use of the existing `Notice()` function, so we don't need to duplicate some code related to sending notices.
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/getsentry/sentry-go"
|
||||
"maunium.net/go/mautrix/event"
|
||||
"maunium.net/go/mautrix/format"
|
||||
"maunium.net/go/mautrix/id"
|
||||
|
||||
"gitlab.com/etke.cc/postmoogle/utils"
|
||||
@@ -115,21 +114,16 @@ func (b *Bot) sendHelp(ctx context.Context, roomID id.RoomID) {
|
||||
defer span.Finish()
|
||||
|
||||
var msg strings.Builder
|
||||
msg.WriteString("the following commands are supported:\n\n")
|
||||
msg.WriteString("The following commands are supported:\n\n")
|
||||
for _, command := range commands {
|
||||
msg.WriteString("* **")
|
||||
msg.WriteString(command.key)
|
||||
msg.WriteString(fmt.Sprintf("`%s %s`", b.prefix, command.key))
|
||||
msg.WriteString("** - ")
|
||||
msg.WriteString(command.description)
|
||||
msg.WriteString("\n")
|
||||
}
|
||||
|
||||
content := format.RenderMarkdown(msg.String(), true, true)
|
||||
content.MsgType = event.MsgNotice
|
||||
_, err := b.lp.Send(roomID, content)
|
||||
if err != nil {
|
||||
b.Error(span.Context(), roomID, "cannot send message: %v", err)
|
||||
}
|
||||
b.Notice(ctx, roomID, msg.String())
|
||||
}
|
||||
|
||||
func (b *Bot) runStop(ctx context.Context, evt *event.Event) {
|
||||
|
||||
Reference in New Issue
Block a user