-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
26 additions
and
21 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import requests | ||
import re | ||
import json | ||
|
||
def send_to_discord_webhook(webhook_url, text): | ||
data = { | ||
"content": text | ||
} | ||
headers = { | ||
"Content-Type": "application/json" | ||
} | ||
try: | ||
if len(text) > 1800: | ||
for i in range(0, len(text), 1800): | ||
data["content"] = text[i:i+1800] | ||
response = requests.post(webhook_url, data=json.dumps(data), headers=headers) | ||
if response.status_code == 429: | ||
print("Discord webhook is being rate limited.") | ||
else: | ||
response = requests.post(webhook_url, data=json.dumps(data), headers=headers) | ||
if response.status_code == 429: | ||
print("Discord webhook is being rate limited.") | ||
except: | ||
print("Failed to send message to Discord webhook.") | ||
pass |
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