From 6ce69d9ff3eaf38966dadac923b8499ab850cceb Mon Sep 17 00:00:00 2001 From: tokinaa Date: Fri, 16 Feb 2024 13:50:37 +0800 Subject: [PATCH] fix: check if degen account have allowance --- main.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index abf7e3b..197c6a5 100644 --- a/main.go +++ b/main.go @@ -226,7 +226,14 @@ func autoTimeline() { return } - remainingAllowance, _ := strconv.Atoi(myAllowance[0].RemainingAllowance) + remainingAllowance := 0 + + if len(myAllowance) == 0 { + fmt.Printf("[DEGEN] [ALLOWANCE] No Allowance\n") + } + + convertAllowance, _ := strconv.Atoi(myAllowance[0].RemainingAllowance) + remainingAllowance = convertAllowance fmt.Printf("| Allowance : %s | Remaining Allowance : %s\n", myAllowance[0].TipAllowance, myAllowance[0].RemainingAllowance) @@ -289,13 +296,19 @@ func autoTimeline() { commentText = fmt.Sprintf("%d $DEGEN", randomThreeDigit) } - if commentText != "" { + if commentText != "" && remainingAllowance > 0 { _, err := warpcast.Comment(myConfig.Accounts[inputSelectAccount], item.Cast.Hash, commentText) if err != nil { fmt.Printf(" ERROR : %s", err) } else { fmt.Printf(" SUCCESS [%s]", commentText) } + } else { + if remainingAllowance == 0 { + fmt.Printf(" SKIP NO ALLOWANCE") + } else { + fmt.Printf(" SKIPPED") + } } fmt.Printf(" ")