-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
190 lines (168 loc) · 5.12 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
package main
import (
"github.com/fatih/color"
"time"
"fmt"
"net/http"
"os"
"bufio"
"os/exec"
"bytes"
"encoding/json"
"io/ioutil"
"github.com/tidwall/gjson"
)
var (
variable string
endpoint string
gid string
TOKEN_AUTH string
logo = `
M""""""'YMM oo 8P
M mmmm. 'M 88
M MMMMM M dP .d8888b. .d8888b. .d8888b. 88d888b. .d888b88
M MMMMM M 88 Y8ooooo. 88' '"" 88' '88 88' '88 88' '88
M MMMM' .M 88 88 88. ... 88. .88 88 88. .88
M .MM dP '88888P' '88888P' '88888P' dP '88888P8
MMMMMMMMMMM
MM'"""""'MM
M' .mmm. 'M
M MMMMMMMM 88d888b. .d8888b. dP dP 88d888b.
M MMM 'M 88' '88 88' '88 88 88 88' '88
M. 'MMM' .M 88 88. .88 88. .88 88. .88
MM. .MM dP '88888P' '88888P' 88Y888P'
MMMMMMMMMMM 88
M""""""'YMM MMP"""""YMM MP""""""'MM
M mmmm. 'M M' .mmm. 'M M mmmmm..M
M MMMMM M M MMMMM M M. 'YM
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)
)
func error_nil(err error) {
if err != nil {
panic(err)
}
}
func main() {
file, err := os.Open("token.txt")
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()
}
if scanner.Err() != nil {
red.Println("ERROR: token.txt read error")
return
}
clear()
red.Println(logo)
slow_print("by elliot")
sleep(400)
clear()
blue.Print("group id: ")
fmt.Scan(&gid)
test_body, test_code := make_request(gid)
switch test_code {
case 401:
red.Println("ERROR: Bad token")
return
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")
sleep(1000)
check_time_body, _ := make_request(gid)
check_time_body_retry := gjson.Get(check_time_body, "retry_after").Int()
for check_time_body_retry <= 500 {
blue.Println("waiting for ratelimit to end")
check_time_body, _ = make_request(gid)
check_time_body_retry = gjson.Get(check_time_body, "retry_after").Int()
clear()
}
yellow.Println("ratelimit ended, locking group again")
}else {
green.Println("already locked")
sleep(1000)
}
}else {
yellow.Println("locking")
spam(gid)
}
for {
test_body, _ := make_request(gid)
clear()
if len(test_body) > 2 {
retry_after := gjson.Get(test_body, "retry_after")
switch {
case retry_after.Int() <= 1000:
yellow.Println("locking again")
spam(gid)
case retry_after.Int() <= 3000:
clear()
blue.Println("locking soon")
case retry_after.String() != "You are being rate limited.":
green.Println("locked")
blue.Print("remaining time: ")
fmt.Println(retry_after.String())
}
}else{
spam(gid)
}
}
}
func slow_print(s string){
for c := 0; c < len(s);c++ {
f := bufio.NewWriter(os.Stdout)
f.Write([]byte(string(s[c])))
f.Flush()
sleep(70)
}
}
func clear() {
cmd := exec.Command("clear")
cmd.Stdout = os.Stdout
cmd.Run()
cmd = exec.Command("cmd", "/c", "cls")
cmd.Stdout = os.Stdout
cmd.Run()
}
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"
empty, _ := json.Marshal("")
request, err := http.NewRequest(http.MethodPut, httpputturl, bytes.NewBuffer(empty))
error_nil(err)
request.Header.Set("Content-Type", "application/json; charset=UTF-8")
request.Header.Set("authorization", TOKEN_AUTH)
request.Header.Set("user-agent", "Discord/21295 CFNetwork/1128.0.1 Darwin/19.6.0")
client := &http.Client{}
response, err := client.Do(request)
error_nil(err)
defer response.Body.Close()
body_bytes, _ := ioutil.ReadAll(response.Body)
body := string(body_bytes)
return body, response.StatusCode
}
func spam(gid string) {
for i := 1; i <= 100; i++ {
go make_request(gid)
}
sleep(1000)
return
}