Add a muc option (useless yet)

This commit is contained in:
Bohdan Horbeshko 2022-07-07 18:23:50 -04:00
parent 0c71036148
commit afa21e10be
2 changed files with 13 additions and 0 deletions

View file

@ -39,6 +39,7 @@ type Session struct {
KeepOnline bool `yaml:":keeponline"`
RawMessages bool `yaml:":rawmessages"`
AsciiArrows bool `yaml:":asciiarrows"`
MUC bool `yaml:":muc"`
}
var configKeys = []string{
@ -46,6 +47,7 @@ var configKeys = []string{
"keeponline",
"rawmessages",
"asciiarrows",
"muc",
}
var sessionDB *SessionsYamlDB
@ -118,6 +120,8 @@ func (s *Session) Get(key string) (string, error) {
return fromBool(s.RawMessages), nil
case "asciiarrows":
return fromBool(s.AsciiArrows), nil
case "muc":
return fromBool(s.MUC), nil
}
return "", errors.New("Unknown session property")
@ -161,6 +165,13 @@ func (s *Session) Set(key string, value string) (string, error) {
}
s.AsciiArrows = b
return value, nil
case "muc":
b, err := toBool(value)
if err != nil {
return "", err
}
s.MUC = b
return value, nil
}
return "", errors.New("Unknown session property")

View file

@ -47,11 +47,13 @@ func TestSessionToMap(t *testing.T) {
session := Session{
Timezone: "klsf",
RawMessages: true,
MUC: true,
}
m := session.ToMap()
sample := map[string]string{
"timezone": "klsf",
"keeponline": "false",
"muc": "true",
"rawmessages": "true",
"asciiarrows": "false",
}