optimize introductions and help, kupo
This commit is contained in:
@@ -134,17 +134,19 @@ func (b *Bot) parseCommand(message string) []string {
|
|||||||
|
|
||||||
func (b *Bot) sendIntroduction(ctx context.Context, roomID id.RoomID) {
|
func (b *Bot) sendIntroduction(ctx context.Context, roomID id.RoomID) {
|
||||||
var msg strings.Builder
|
var msg strings.Builder
|
||||||
msg.WriteString("Hello!\n\n")
|
msg.WriteString("Hello, kupo!\n\n")
|
||||||
|
|
||||||
msg.WriteString("This is Postmoogle - a bot that bridges Email to Matrix.\n\n")
|
msg.WriteString("This is Postmoogle - a bot that bridges Email to Matrix.\n\n")
|
||||||
msg.WriteString(fmt.Sprintf(
|
|
||||||
"To get started, assign an email address to this room by sending a `%s %s SOME_INBOX` command.\n",
|
msg.WriteString("To get started, assign an email address to this room by sending a `")
|
||||||
b.prefix,
|
msg.WriteString(b.prefix)
|
||||||
optionMailbox,
|
msg.WriteString(" ")
|
||||||
))
|
msg.WriteString(optionMailbox)
|
||||||
msg.WriteString(fmt.Sprintf(
|
msg.WriteString("` command.\n")
|
||||||
"You will then be able to send emails to `SOME_INBOX@%s` and have them appear in this room.",
|
|
||||||
b.domain,
|
msg.WriteString("You will then be able to send emails to `SOME_INBOX@")
|
||||||
))
|
msg.WriteString(b.domain)
|
||||||
|
msg.WriteString("` and have them appear in this room.")
|
||||||
|
|
||||||
b.Notice(ctx, roomID, msg.String())
|
b.Notice(ctx, roomID, msg.String())
|
||||||
}
|
}
|
||||||
@@ -153,7 +155,13 @@ func (b *Bot) sendHelp(ctx context.Context, roomID id.RoomID) {
|
|||||||
var msg strings.Builder
|
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 {
|
for _, command := range commands {
|
||||||
msg.WriteString(fmt.Sprintf("* **`%s %s`** - %s\n", b.prefix, command.key, command.description))
|
msg.WriteString("* **`")
|
||||||
|
msg.WriteString(b.prefix)
|
||||||
|
msg.WriteString(" ")
|
||||||
|
msg.WriteString(command.key)
|
||||||
|
msg.WriteString("`** - ")
|
||||||
|
msg.WriteString(command.description)
|
||||||
|
msg.WriteString("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
b.Notice(ctx, roomID, msg.String())
|
b.Notice(ctx, roomID, msg.String())
|
||||||
@@ -209,7 +217,7 @@ func (b *Bot) getOption(ctx context.Context, name string) {
|
|||||||
|
|
||||||
value := cfg.Get(name)
|
value := cfg.Get(name)
|
||||||
if value == "" {
|
if value == "" {
|
||||||
b.Notice(ctx, evt.RoomID, fmt.Sprintf("`%s` is not set", name))
|
b.Notice(ctx, evt.RoomID, fmt.Sprintf("`%s` is not set, kupo.", name))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +240,7 @@ func (b *Bot) setOption(ctx context.Context, name, value string) {
|
|||||||
if name == optionMailbox {
|
if name == optionMailbox {
|
||||||
existingID, ok := b.GetMapping(value)
|
existingID, ok := b.GetMapping(value)
|
||||||
if ok && existingID != "" && existingID != evt.RoomID {
|
if ok && existingID != "" && existingID != evt.RoomID {
|
||||||
b.Notice(ctx, evt.RoomID, fmt.Sprintf("Mailbox `%s@%s` already taken", value, b.domain))
|
b.Notice(ctx, evt.RoomID, fmt.Sprintf("Mailbox `%s@%s` already taken, kupo", value, b.domain))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,7 +252,7 @@ func (b *Bot) setOption(ctx context.Context, name, value string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !cfg.Allowed(b.noowner, evt.Sender) {
|
if !cfg.Allowed(b.noowner, evt.Sender) {
|
||||||
b.Notice(ctx, evt.RoomID, "you don't have permission to do that")
|
b.Notice(ctx, evt.RoomID, "you don't have permission to do that, kupo")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user