Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a170870
commit 39ba3aa
Showing
4 changed files
with
137 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,26 @@ | ||
**you can go in webhook.go and change the name where it says "username :=" of the bot and add ur own icon, put the webhook in config.txt. then run "go build webhook.go" and u will be set, you dont have to re-complie to add a new webhook just close the application and put a new webhook in config.txt and start it back up and it will work** | ||
# Discord Webhook Messenger | ||
|
||
*if u want to add a avatar url just add where it says ""avatar_url" :"* | ||
# Setup | ||
* Open Config.json | ||
* Input Webhook URL | ||
* Avatar URL & Webhook Username are **optional** | ||
|
||
# Usage | ||
``` | ||
usage: Webhook Sender [-h|--help] -m|--message "<value>" [-t|--timeout | ||
<integer>] [-a|--amount <integer>] | ||
Spam a webhook with a message | ||
Arguments: | ||
-h --help Print help information | ||
-m --message Message to Send Through Webhook | ||
-t --timeout Time Between Messages In Seconds | ||
-a --amount Amount Of Times To Send Message | ||
``` | ||
|
||
# Example | ||
``go run webhook.go -m hello -t 5 -a 50`` **Send the message "hello" every 5 seconds 50 times** | ||
|
||
**MADE BY cookie#0003 ON DISCORD** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"webhook_url": "Webhook Here", | ||
"webhook_username": "", | ||
"avatar_url": "" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,120 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
"net/url" | ||
"io/ioutil" | ||
"net/http" | ||
"os" | ||
"strconv" | ||
"time" | ||
|
||
"github.com/akamensky/argparse" | ||
) | ||
|
||
func main() { | ||
|
||
webhook, err := ioutil.ReadFile("config.txt") | ||
if err == nil { | ||
fmt.Println("Webhook message sender | Made by: cookie#0003") | ||
//JSONConfig struct for config.json file | ||
type JSONConfig struct { | ||
WebhookURL string `json:"webhook_url"` | ||
WebhookUsername string `json:"webhook_username"` | ||
AvatarURL string `json:"avatar_url"` | ||
} | ||
|
||
//ErrorResponse struct for Discord Ratelimit response | ||
type ErrorResponse struct { | ||
Message string `json:"message"` | ||
RetryAfter int `json:"retry_after"` | ||
} | ||
|
||
var ( | ||
webhook string | ||
avatar string | ||
message *string | ||
timeout *int | ||
amount *int | ||
client *http.Client = &http.Client{} | ||
) | ||
|
||
func readConfig() (string, string, string) { | ||
file, err := ioutil.ReadFile("config.json") | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
data := JSONConfig{} | ||
|
||
err = json.Unmarshal([]byte(file), &data) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
return data.WebhookURL, data.WebhookUsername, data.AvatarURL | ||
} | ||
|
||
func spamWebhook(webhook string, avatar string, message *string, username string, timeout *int, amount *int) { | ||
if *amount == 0 { | ||
for { | ||
var e ErrorResponse | ||
jsonStr := []byte(fmt.Sprintf(`{"content": "%s", "username": "%s", "avatar_url": "%s"}`, *message, username, avatar)) | ||
|
||
req, err := http.NewRequest("POST", webhook, bytes.NewBuffer(jsonStr)) | ||
req.Header.Set("Content-Type", "application/json") | ||
|
||
res, err := client.Do(req) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
body, err := ioutil.ReadAll(res.Body) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
err = json.Unmarshal(body, &e) | ||
if err == nil { | ||
fmt.Println("You Are Being Ratelimited Waiting " + strconv.Itoa(e.RetryAfter) + " Milliseconds") | ||
time.Sleep(time.Duration(e.RetryAfter+5) * time.Millisecond) | ||
} | ||
time.Sleep(time.Duration(*timeout) * time.Second) | ||
} | ||
|
||
for { | ||
fmt.Printf("\nMessage: ") | ||
var MESSAGE string | ||
fmt.Scanln(&MESSAGE) | ||
|
||
username := "cookie v2" | ||
data := url.Values{ | ||
"content": {MESSAGE}, | ||
"username": {username}, | ||
"avatar_url": {""}, | ||
} else { | ||
for i := 0; i < *amount; i++ { | ||
var e ErrorResponse | ||
jsonStr := []byte(fmt.Sprintf(`{"content": "%s", "username": "%s", "avatar_url": "%s"}`, *message, username, avatar)) | ||
|
||
req, err := http.NewRequest("POST", webhook, bytes.NewBuffer(jsonStr)) | ||
req.Header.Set("Content-Type", "application/json") | ||
|
||
res, err := client.Do(req) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
body, err := ioutil.ReadAll(res.Body) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
err = json.Unmarshal(body, &e) | ||
if err == nil { | ||
fmt.Println("You Are Being Ratelimited Waiting " + strconv.Itoa(e.RetryAfter) + " Milliseconds") | ||
time.Sleep(time.Duration(e.RetryAfter+5) * time.Millisecond) | ||
} | ||
time.Sleep(time.Duration(*timeout) * time.Second) | ||
} | ||
http.PostForm(string(webhook), data) | ||
} | ||
} | ||
|
||
func main() { | ||
|
||
parser := argparse.NewParser("Webhook Sender", "Spam a webhook with a message") | ||
message = parser.String("m", "message", &argparse.Options{Required: true, Help: "Message to Send Through Webhook"}) | ||
timeout = parser.Int("t", "timeout", &argparse.Options{Required: false, Help: "Time Between Messages In Seconds"}) | ||
amount = parser.Int("a", "amount", &argparse.Options{Required: false, Help: "Amount Of Times To Send Message"}) | ||
err := parser.Parse(os.Args) | ||
if err != nil { | ||
fmt.Println(parser.Usage(err)) | ||
os.Exit(0) | ||
} | ||
fmt.Println("Webhook message sender | Made by: cookie#0003") | ||
webhook, username, avatar := readConfig() | ||
|
||
} | ||
spamWebhook(webhook, avatar, message, username, timeout, amount) | ||
} |