summaryrefslogtreecommitdiffstats
path: root/bridge/bridge.go
diff options
context:
space:
mode:
authorQais Patankar <qaisjp@gmail.com>2020-06-24 23:25:10 +0100
committerGitHub <noreply@github.com>2020-06-25 00:25:10 +0200
commita41accd033a8d7e859a4bff89ae64e1f3500e4d2 (patch)
treee7b86f05c725632b2e285ac1ee42f669819dfc32 /bridge/bridge.go
parent37f7caf7f398bfab7acffe3e0dda443ed2ca041d (diff)
downloadmatterbridge-msglm-a41accd033a8d7e859a4bff89ae64e1f3500e4d2.tar.gz
matterbridge-msglm-a41accd033a8d7e859a4bff89ae64e1f3500e4d2.tar.bz2
matterbridge-msglm-a41accd033a8d7e859a4bff89ae64e1f3500e4d2.zip
Add sane RemoteNickFormat default for API (#1157)
Diffstat (limited to 'bridge/bridge.go')
-rw-r--r--bridge/bridge.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/bridge/bridge.go b/bridge/bridge.go
index eec2bfaf..ef71f97e 100644
--- a/bridge/bridge.go
+++ b/bridge/bridge.go
@@ -86,8 +86,16 @@ func (b *Bridge) joinChannels(channels map[string]config.ChannelInfo, exists map
return nil
}
+func (b *Bridge) GetConfigKey(key string) string {
+ return b.Account + "." + key
+}
+
+func (b *Bridge) IsKeySet(key string) bool {
+ return b.Config.IsKeySet(b.GetConfigKey(key)) || b.Config.IsKeySet("general."+key)
+}
+
func (b *Bridge) GetBool(key string) bool {
- val, ok := b.Config.GetBool(b.Account + "." + key)
+ val, ok := b.Config.GetBool(b.GetConfigKey(key))
if !ok {
val, _ = b.Config.GetBool("general." + key)
}
@@ -95,7 +103,7 @@ func (b *Bridge) GetBool(key string) bool {
}
func (b *Bridge) GetInt(key string) int {
- val, ok := b.Config.GetInt(b.Account + "." + key)
+ val, ok := b.Config.GetInt(b.GetConfigKey(key))
if !ok {
val, _ = b.Config.GetInt("general." + key)
}
@@ -103,7 +111,7 @@ func (b *Bridge) GetInt(key string) int {
}
func (b *Bridge) GetString(key string) string {
- val, ok := b.Config.GetString(b.Account + "." + key)
+ val, ok := b.Config.GetString(b.GetConfigKey(key))
if !ok {
val, _ = b.Config.GetString("general." + key)
}
@@ -111,7 +119,7 @@ func (b *Bridge) GetString(key string) string {
}
func (b *Bridge) GetStringSlice(key string) []string {
- val, ok := b.Config.GetStringSlice(b.Account + "." + key)
+ val, ok := b.Config.GetStringSlice(b.GetConfigKey(key))
if !ok {
val, _ = b.Config.GetStringSlice("general." + key)
}
@@ -119,7 +127,7 @@ func (b *Bridge) GetStringSlice(key string) []string {
}
func (b *Bridge) GetStringSlice2D(key string) [][]string {
- val, ok := b.Config.GetStringSlice2D(b.Account + "." + key)
+ val, ok := b.Config.GetStringSlice2D(b.GetConfigKey(key))
if !ok {
val, _ = b.Config.GetStringSlice2D("general." + key)
}