From 33c77d14d8d2529363b4a3d3bb616bb77a981ed0 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Wed, 28 Jun 2023 18:51:54 +0530 Subject: [PATCH 1/1] patch for https://git.sinanmohd.com/zukbeam * disable log colors * write raw qr code value to stdout * make a 512x512 png of qrcode on working directory --- mdtest/go.mod | 1 + mdtest/go.sum | 2 ++ mdtest/main.go | 9 ++++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mdtest/go.mod b/mdtest/go.mod index c687e5e..f3e9087 100644 --- a/mdtest/go.mod +++ b/mdtest/go.mod @@ -12,6 +12,7 @@ require ( require ( filippo.io/edwards25519 v1.0.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect + github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect go.mau.fi/libsignal v0.1.0 // indirect golang.org/x/crypto v0.8.0 // indirect rsc.io/qr v0.2.0 // indirect diff --git a/mdtest/go.sum b/mdtest/go.sum index 3e42961..441aa5d 100644 --- a/mdtest/go.sum +++ b/mdtest/go.sum @@ -12,6 +12,8 @@ github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S github.com/mdp/qrterminal v1.0.1/go.mod h1:Z33WhxQe9B6CdW37HaVqcRKzP+kByF3q/qLxOGe12xQ= github.com/mdp/qrterminal/v3 v3.0.0 h1:ywQqLRBXWTktytQNDKFjhAvoGkLVN3J2tAFZ0kMd9xQ= github.com/mdp/qrterminal/v3 v3.0.0/go.mod h1:NJpfAs7OAm77Dy8EkWrtE4aq+cE6McoLXlBqXQEwvE0= +github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0= +github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M= go.mau.fi/libsignal v0.1.0 h1:vAKI/nJ5tMhdzke4cTK1fb0idJzz1JuEIpmjprueC+c= go.mau.fi/libsignal v0.1.0/go.mod h1:R8ovrTezxtUNzCQE5PH30StOQWWeBskBsWE55vMfY9I= golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ= diff --git a/mdtest/main.go b/mdtest/main.go index 8a1356f..a4236a7 100644 --- a/mdtest/main.go +++ b/mdtest/main.go @@ -26,6 +26,7 @@ import ( _ "github.com/mattn/go-sqlite3" "github.com/mdp/qrterminal/v3" + qrcode "github.com/skip2/go-qrcode" "google.golang.org/protobuf/proto" "go.mau.fi/whatsmeow" @@ -59,9 +60,9 @@ func main() { if *requestFullSync { store.DeviceProps.RequireFullSync = proto.Bool(true) } - log = waLog.Stdout("Main", logLevel, true) + log = waLog.Stdout("Main", logLevel, false) - dbLog := waLog.Stdout("Database", logLevel, true) + dbLog := waLog.Stdout("Database", logLevel, false) storeContainer, err := sqlstore.New(*dbDialect, *dbAddress, dbLog) if err != nil { log.Errorf("Failed to connect to database: %v", err) @@ -73,7 +74,7 @@ func main() { return } - cli = whatsmeow.NewClient(device, waLog.Stdout("Client", logLevel, true)) + cli = whatsmeow.NewClient(device, waLog.Stdout("Client", logLevel, false)) var isWaitingForPair atomic.Bool cli.PrePairCallback = func(jid types.JID, platform, businessName string) bool { isWaitingForPair.Store(true) @@ -102,6 +103,8 @@ func main() { for evt := range ch { if evt.Event == "code" { qrterminal.GenerateHalfBlock(evt.Code, qrterminal.L, os.Stdout) + qrcode.WriteFile(evt.Code, qrcode.Medium, 512, "qr.png") + log.Infof("QR code raw: %s", evt.Code) } else { log.Infof("QR channel result: %s", evt.Event) } -- 2.41.0