Skip to content

Commit

Permalink
update fix wait login process until it's timed out
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaskiddo committed Dec 1, 2023
1 parent 19b0251 commit 6835e13
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"strconv"
"time"

"github.com/spf13/cobra"

Expand All @@ -26,12 +27,12 @@ var Login = &cobra.Command{

fmt.Println("")
fmt.Println("Please Insert Your Phone Number to Generate Pair Code:")
phoneInput := bufio.NewReader(os.Stdin)
fmt.Println("")

phoneInput := bufio.NewReader(os.Stdin)
phoneNumber, err := phoneInput.ReadString('\n')
if err != nil {
log.Println(log.LogLevelError, "Failed to Get Phone Number Input!")
return
}

pairResponse, pairTimeout, err := pkgWhatsApp.WhatsAppLogin(phoneNumber)
Expand All @@ -45,8 +46,11 @@ var Login = &cobra.Command{
return
}

fmt.Println("")
log.Println(log.LogLevelInfo, "Successfully Generate Pair Code. Your Pair Code is "+pairResponse)
log.Println(log.LogLevelInfo, "Pair Code Will Be Expired in "+strconv.Itoa(pairTimeout)+"s")

time.Sleep(time.Duration(pairTimeout) * time.Second)
} else {
log.Println(log.LogLevelInfo, "WhatsApp Client Already Logged-in")
}
Expand Down

0 comments on commit 6835e13

Please sign in to comment.