-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
191 lines (164 loc) · 3.77 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
191
package main
import (
"bufio"
"bytes"
"encoding/json"
"fmt"
"github.com/fatih/color"
"github.com/gtuk/discordwebhook"
"github.com/inancgumus/screen"
"github.com/lukesampson/figlet/figletlib"
"golang.org/x/term"
"io/ioutil"
"net/http"
"os"
"path/filepath"
"strings"
"sync"
"time"
"unicode/utf8"
)
type person struct {
whmessage string
}
var (
width, _, err = term.GetSize(0)
)
type Data struct {
Username string
Messages string
}
func readLines(path string) ([]string, error) {
file, err := os.Open(path)
if err != nil {
return nil, err
}
defer file.Close()
var lines []string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
return lines, scanner.Err()
}
func ErrorCheck(err error) {
if err != nil {
msg := strings.Trim(err.Error(), "\n")
fmt.Println(Pretty(msg))
}
}
func NCenter(width int, s string) *bytes.Buffer {
const half, space = 2, "\u0020"
var b bytes.Buffer
n := (width - utf8.RuneCountInString(s)) / half
fmt.Fprintf(&b, "%s%s", strings.Repeat(space, n), s)
return &b
}
type erorr struct {
Global bool `json:"global"`
Message string `json:"message"`
Retry_after int `json:"retry_after"`
}
func Pretty(info string) string {
pretty := ""
pretty += color.HiMagentaString("[")
pretty += color.WhiteString("+")
pretty += color.HiMagentaString("] ")
pretty += info
return pretty
}
func Clear() {
screen.Clear()
}
func Border() {
i := 0
res1 := ""
for i < width {
res1 += "─"
i += 1
}
fmt.Println(res1)
}
func Logo() {
cwd, _ := os.Getwd()
fontsdir := filepath.Join(cwd, "data")
ErrorCheck(err)
f, err := figletlib.GetFontByName(fontsdir, "4max")
ErrorCheck(err)
color.Set(color.FgHiMagenta)
figletlib.PrintMsg("Kyanite", f, width, f.Settings(), "center")
color.Set(color.FgHiWhite)
fmt.Println()
fmt.Println()
Border()
}
func Delete(webhook string) {
client := &http.Client{}
req, err := http.NewRequest("DELETE", webhook, nil)
ErrorCheck(err)
resp, err := client.Do(req)
ErrorCheck(err)
defer resp.Body.Close()
_, err = ioutil.ReadAll(resp.Body)
ErrorCheck(err)
var ReplacedWebhook string = strings.Replace(webhook, "https://", "", 0)
var SplitWebhook []string = strings.Split(ReplacedWebhook, "/")
if strings.Contains(resp.Status, "204") {
fmt.Println(Pretty("- Succesfully Deleted Webhook: " + SplitWebhook[5]))
}
}
func Spam(username string, content string, webhook string, amount int, delete_after bool, wg *sync.WaitGroup) {
defer wg.Done()
message := discordwebhook.Message{
Username: &username,
Content: &content,
}
for i := 1; i <= amount; i++ {
err := discordwebhook.SendMessage(webhook, message)
if err != nil {
if strings.Contains(err.Error(), "rate limit") {
var errors erorr
json.Unmarshal([]byte(err.Error()), &errors)
i = i - 1
}
} else {
fmt.Println(Pretty("- Sent Message: " + content))
}
}
if delete_after {
go Delete(webhook)
time.Sleep(2 * time.Second)
}
}
func main() {
var wg sync.WaitGroup
Clear()
Logo()
content, err := ioutil.ReadFile("main.json")
ErrorCheck(err)
var payload Data
err = json.Unmarshal(content, &payload)
ErrorCheck(err)
var username string = payload.Username
var message string = payload.Messages
var amount int
var delete_string string
var delete_after bool
fmt.Println()
fmt.Print(Pretty("Amount: "))
color.Set(color.FgHiMagenta)
fmt.Scanln(&amount)
fmt.Print(Pretty("Delete After [Y/N]: "))
color.Set(color.FgHiMagenta)
fmt.Scanln(&delete_string)
delete_after = strings.Contains(strings.ToLower(delete_string), "y")
fmt.Println()
color.Set(color.FgHiWhite)
Border()
lines, err := readLines("webhooks.txt")
for sex, webhook := range lines {
wg.Add(sex)
go Spam(username, message, webhook, amount, delete_after, &wg)
}
time.Sleep(500000 * time.Minute)
}