Get rid of various duplicated optionMailbox formatting

`formatOptionValue` takes care of these now.

Besides fixing the duplication, this also fixes the lint error
affecting `sendHelp` - high complexity.
This commit is contained in:
Slavi Pantaleev
2022-08-27 19:35:45 +03:00
parent 972b4c11c5
commit c8331e9958
2 changed files with 26 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
package bot
import (
"fmt"
"strconv"
"strings"
@@ -118,3 +119,15 @@ func (b *Bot) getSettings(roomID id.RoomID) (settings, error) {
func (b *Bot) setSettings(roomID id.RoomID, cfg settings) error {
return b.lp.GetClient().SetRoomAccountData(roomID, settingskey, cfg)
}
func (b *Bot) formatOptionValue(name string, value string) string {
if value == "" {
return value
}
if name == optionMailbox {
value = fmt.Sprintf("%s@%s", value, b.domain)
}
return value
}