diff --git a/bridge/bridge.go b/bridge/bridge.go index 6b955a9e..4e705cda 100644 --- a/bridge/bridge.go +++ b/bridge/bridge.go @@ -88,6 +88,16 @@ func (b *Bridge) GetBool(key string) bool { return val } +func (b *Bridge) GetBoolOrDefault(key string, thedefault bool) bool { + val, ok := b.Config.GetBool(b.Account + "." + key) + if !ok { + if val, ok = b.Config.GetBool("general." + key); !ok { + return thedefault + } + } + return val +} + func (b *Bridge) GetInt(key string) int { val, ok := b.Config.GetInt(b.Account + "." + key) if !ok { diff --git a/bridge/whatsapp/whatsapp.go b/bridge/whatsapp/whatsapp.go index b8c6483a..0e5146ec 100644 --- a/bridge/whatsapp/whatsapp.go +++ b/bridge/whatsapp/whatsapp.go @@ -159,8 +159,8 @@ func (b *Bwhatsapp) Login() error { // TODO qrCode, err := qrcode.Encode(code, qrcode.Low, 256) to encode as image/png // and possibly send it to connected channels (to admin) to authorize the app - // TODO invert configured in settings - qrChan := qrFromTerminal(true) + invert := b.GetBoolOrDefault("QrOnWhiteTerminal", false) + qrChan := qrFromTerminal(invert) session, err := b.conn.Login(qrChan) if err != nil { diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index f5a20ae8..d5e6aed0 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -1162,6 +1162,10 @@ Number="+48111222333" # optional (by default the session is stored only in memory, till restarting matterbridge) SessionFile="session-48111222333.gob" +# If your terminal is white we need to invert QR code in order for it to be scanned properly +# optional (default false) +QrOnWhiteTerminal=true + # Messages will be seen by other WhatsApp contacts as coming from the bridge. Original nick will be part of the message. RemoteNickFormat="@{NICK}: "