forked from WeaveAche/hanime-auto-coins-collector
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webhook.py
32 lines (27 loc) · 1.04 KB
/
webhook.py
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
#THIS FILE SENDS THE HOUSE.TXT FILE CONTENT TO THE WEBHOOK
import requests
import os
def send_to_discord_webhook(webhook_url, file_path):
try:
# Read the content of the file
with open(file_path, 'r') as file:
content = file.read()
# Prepare the payload to be sent to the Discord webhook
payload = {
'content': content
}
# Send the payload to the webhook URL
response = requests.post(webhook_url, json=payload)
# Check if the request was successful
if response.status_code == 204:
pass
else:
print("Failed to send content to Discord. Status code:", response.status_code)
except FileNotFoundError:
print("File not found. Please check the file path.")
#THIS IS TO CONFIGURE THE WEBHOOK
if __name__ == "__main__":
webhook_url = os.environ["WEBHOOK_URL"]
file_path = "house.txt" # Update the file path accordingly
#-CONFIG END-
send_to_discord_webhook(webhook_url, file_path)