From eb1ef4506bdb5c041ae3686689f9195831fffed7 Mon Sep 17 00:00:00 2001 From: usaginc <158854822+usaginc@users.noreply.github.com> Date: Mon, 5 Feb 2024 22:00:43 +0100 Subject: [PATCH 1/4] Update main.go --- main.go | 67 ++++++++++++++++++++++++++------------------------------- 1 file changed, 30 insertions(+), 37 deletions(-) diff --git a/main.go b/main.go index 3802bb9..0554d78 100644 --- a/main.go +++ b/main.go @@ -16,9 +16,9 @@ import ( var ( - variable string - endpoint string - gid string + variable string + endpoint string + gid string TOKEN_AUTH string logo = ` M""""""'YMM oo 8P @@ -42,28 +42,30 @@ M MMMMM M M MMMMM M MMMMMMM. M M MMMM' .M M. 'MMM' .M M. .MMM' M M .MM MMb dMM Mb. .dM MMMMMMMMMMM MMMMMMMMMMM MMMMMMMMMMM -` -blue = color.New(color.Bold, color.FgHiBlue) -red = color.New(color.Bold, color.FgHiRed) -yellow = color.New(color.Bold, color.FgHiYellow) -green = color.New(color.Bold, color.FgHiGreen) + ` + blue = color.New(color.Bold, color.FgHiBlue) + red = color.New(color.Bold, color.FgHiRed) + yellow = color.New(color.Bold, color.FgHiYellow) + green = color.New(color.Bold, color.FgHiGreen) ) - -func main() { - file, err := os.Open("token.txt") +func error_nil(err error) { if err != nil { fmt.Println(err) } +} + +func main() { + file, err := os.Open("token.txt") + error_nil(err) defer file.Close() scanner := bufio.NewScanner(file) for scanner.Scan() { TOKEN_AUTH = scanner.Text() } - - if err := scanner.Err(); err != nil { - fmt.Println(err) - } + + error_nil(scanner.Err()) + clear() red.Println(logo) slow_print("by elliot") @@ -73,14 +75,14 @@ func main() { blue.Print("group id: ") fmt.Scan(&gid) test_body, test_code := make_request(gid) - if test_code == 401 { - + switch test_code { + case 401: red.Println("ERROR BAD TOKEN") return - } - if test_code == 403 { + case 403: red.Println("ERROR NOT IN GROUP") } + if len(test_body) > 2 && gjson.Get(test_body, "message").String() == "You are being rate limited." { if gjson.Get(test_body, "retry_after").Int() <= 500 { green.Println("already locked") @@ -107,21 +109,19 @@ func main() { test_body, _ := make_request(gid) clear() if len(test_body) > 2 { - if gjson.Get(test_body, "retry_after").Int() <= 500 { + retry_after := gjson.Get(test_body, "retry_after") + switch { + case retry_after.Int() <= 500: yellow.Println("locking again") spam(gid) - }else if gjson.Get(test_body, "retry_after").Int() <= 5000 { + case retry_after.Int() <= 5000: clear() blue.Println("locking soon") spam(gid) - }else if gjson.Get(test_body, "message").String() != "You are being rate limited." { - yellow.Println("locking again") - spam(gid) - green.Println("locked") - }else { + case retry_after.String() != "You are being rate limited.": green.Println("locked") blue.Print("remaining time: ") - fmt.Println(gjson.Get(test_body, "retry_after").String()) + fmt.Println(retry_after.String()) } }else{ spam(gid) @@ -129,7 +129,6 @@ func main() { } } - func slow_print(s string){ for c := 0; c < len(s);c++ { f := bufio.NewWriter(os.Stdout) @@ -139,7 +138,6 @@ func slow_print(s string){ } } - func clear() { cmd := exec.Command("clear") cmd.Stdout = os.Stdout @@ -153,7 +151,6 @@ func sleep(t time.Duration){ time.Sleep(t * time.Millisecond) } - func make_request(gid string) (string, int) { gid = fmt.Sprintf(gid) httpputturl := "https://discord.com/api/v7/channels/" + gid + "/recipients/1337" @@ -161,9 +158,7 @@ func make_request(gid string) (string, int) { empty, _ := json.Marshal("") request, err := http.NewRequest(http.MethodPut, httpputturl, bytes.NewBuffer(empty)) - if err != nil { - panic(err) - } + error_nil(err) request.Header.Set("Content-Type", "application/json; charset=UTF-8") request.Header.Set("authorization", TOKEN_AUTH) @@ -172,9 +167,8 @@ func make_request(gid string) (string, int) { client := &http.Client{} response, err := client.Do(request) - if err != nil { - panic(err) - } + error_nil(err) + defer response.Body.Close() body_bytes, _ := ioutil.ReadAll(response.Body) body := string(body_bytes) @@ -189,4 +183,3 @@ func spam(gid string) { sleep(4600) return } - From c2f3a8dc198d1063a4d0f0fc415098a35d851c95 Mon Sep 17 00:00:00 2001 From: elliot <116954050+e-lliot@users.noreply.github.com> Date: Wed, 20 Mar 2024 02:47:07 -0400 Subject: [PATCH 2/4] Update main.go --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 0554d78..ada4340 100644 --- a/main.go +++ b/main.go @@ -111,10 +111,10 @@ func main() { if len(test_body) > 2 { retry_after := gjson.Get(test_body, "retry_after") switch { - case retry_after.Int() <= 500: + case retry_after.Int() <= 1000: yellow.Println("locking again") spam(gid) - case retry_after.Int() <= 5000: + case retry_after.Int() <= 10000: clear() blue.Println("locking soon") spam(gid) From 522d420f6e6755aef029c777aa8e7e26ae161a01 Mon Sep 17 00:00:00 2001 From: elliot <116954050+e-lliot@users.noreply.github.com> Date: Wed, 20 Mar 2024 02:49:00 -0400 Subject: [PATCH 3/4] Update main.go --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index ada4340..8ad7071 100644 --- a/main.go +++ b/main.go @@ -51,7 +51,7 @@ MMMMMMMMMMM MMMMMMMMMMM MMMMMMMMMMM func error_nil(err error) { if err != nil { - fmt.Println(err) + panic(err) } } From dd85c35268fe820d7303ee0dffda99c311da189d Mon Sep 17 00:00:00 2001 From: elliot <116954050+e-lliot@users.noreply.github.com> Date: Wed, 20 Mar 2024 03:11:10 -0400 Subject: [PATCH 4/4] Update main.go --- main.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 8ad7071..b9204d2 100644 --- a/main.go +++ b/main.go @@ -57,14 +57,20 @@ func error_nil(err error) { func main() { file, err := os.Open("token.txt") - error_nil(err) + if err != nil { + red.Println("ERROR: No token.txt file / read permission denied") + return + } defer file.Close() scanner := bufio.NewScanner(file) for scanner.Scan() { TOKEN_AUTH = scanner.Text() } - error_nil(scanner.Err()) + if scanner.Err() != nil { + red.Println("ERROR: token.txt read error") + return + } clear() red.Println(logo) @@ -77,10 +83,10 @@ func main() { test_body, test_code := make_request(gid) switch test_code { case 401: - red.Println("ERROR BAD TOKEN") + red.Println("ERROR: Bad token") return case 403: - red.Println("ERROR NOT IN GROUP") + red.Println("ERROR: Not in group") } if len(test_body) > 2 && gjson.Get(test_body, "message").String() == "You are being rate limited." { @@ -114,10 +120,9 @@ func main() { case retry_after.Int() <= 1000: yellow.Println("locking again") spam(gid) - case retry_after.Int() <= 10000: + case retry_after.Int() <= 3000: clear() blue.Println("locking soon") - spam(gid) case retry_after.String() != "You are being rate limited.": green.Println("locked") blue.Print("remaining time: ") @@ -177,9 +182,9 @@ func make_request(gid string) (string, int) { } func spam(gid string) { - for i := 1; i <= 50; i++ { + for i := 1; i <= 100; i++ { go make_request(gid) } - sleep(4600) + sleep(1000) return }