Show option values in help
Before: > * **`!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) > * **`!pm nohtml`** - Get or set `nohtml` of the room (`true` - ignore HTML in email; `false` - parse HTML in emails) > * **`!pm nothreads`** - Get or set `nothreads` of the room (`true` - ignore email threads; `false` - convert email threads into matrix threads) > * **`!pm nofiles`** - Get or set `nofiles` of the room (`true` - ignore email attachments; `false` - upload email attachments After: > * **`!pm help`** - Show this help message > * **`!pm stop`** - Disable bridge for the room and clear all configuration > * **`!pm mailbox`** (currently `something@example.com`) - Get or set mailbox of the room > * **`!pm owner`** (currently `@someone:example.com`) - Get or set owner of the room > * **`!pm nosender`** (currently `false`) - Get or set `nosender` of the room (`true` - hide email sender; `false` - show email sender) > * **`!pm nosubject`** (currently `true`) - Get or set `nosubject` of the room (`true` - hide email subject; `false` - show email subject) > * **`!pm nohtml`** (currently `false`) - Get or set `nohtml` of the room (`true` - ignore HTML in email; `false` - parse HTML in emails) > * **`!pm nothreads`** (currently `false`) - Get or set `nothreads` of the room (`true` - ignore email threads; `false` - convert email threads into matrix threads) > * **`!pm nofiles`** (currently `false`) - Get or set `nofiles` of the room (`true` - ignore email attachments; `false` - upload email attachments)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package bot
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -115,6 +116,24 @@ func (b *Bot) getSettings(roomID id.RoomID) (settings, error) {
|
||||
return config, err
|
||||
}
|
||||
|
||||
func (b *Bot) getSettingsOption(roomID id.RoomID, name string) (any, error) {
|
||||
cfg, err := b.getSettings(roomID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to retrieve settings: %v", err)
|
||||
}
|
||||
|
||||
value := cfg.Get(name)
|
||||
if value == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if name == optionMailbox {
|
||||
value = fmt.Sprintf("%s@%s", value, b.domain)
|
||||
}
|
||||
|
||||
return value, nil
|
||||
}
|
||||
|
||||
func (b *Bot) setSettings(roomID id.RoomID, cfg settings) error {
|
||||
return b.lp.GetClient().SetRoomAccountData(roomID, settingskey, cfg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user