From 9929501ecc3fc36b979ebf27a30dde1e3ded5c29 Mon Sep 17 00:00:00 2001 From: Krzysztof Madejski Date: Tue, 12 Feb 2019 16:12:30 +0100 Subject: [PATCH] #475 Extract config options as const --- bridge/whatsapp/whatsapp.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bridge/whatsapp/whatsapp.go b/bridge/whatsapp/whatsapp.go index 0e5146ec..92407d51 100644 --- a/bridge/whatsapp/whatsapp.go +++ b/bridge/whatsapp/whatsapp.go @@ -17,9 +17,10 @@ import ( ) const ( - // Account config parameters - cfgNumber = "Number" + cfgNumber = "Number" + qrOnWhiteTerminal = "QrOnWhiteTerminal" + sessionFile = "SessionFile" ) type Bwhatsapp struct { @@ -159,7 +160,7 @@ 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 - invert := b.GetBoolOrDefault("QrOnWhiteTerminal", false) + invert := b.GetBoolOrDefault(qrOnWhiteTerminal, false) qrChan := qrFromTerminal(invert) session, err := b.conn.Login(qrChan) @@ -203,7 +204,7 @@ func qrFromTerminal(invert bool) chan string { func (b *Bwhatsapp) readSession() (whatsapp.Session, error) { session := whatsapp.Session{} - sessionFile := b.Config.GetString("SessionFile") + sessionFile := b.Config.GetString(sessionFile) if sessionFile == "" { return session, errors.New("If you won't set SessionFile then you will need to scan QR code on every restart") @@ -223,7 +224,7 @@ func (b *Bwhatsapp) readSession() (whatsapp.Session, error) { } func (b *Bwhatsapp) writeSession(session whatsapp.Session) error { - sessionFile := b.Config.GetString("SessionFile") + sessionFile := b.Config.GetString(sessionFile) if sessionFile == "" { // we already sent a warning while starting the bridge, so let's be quiet here