feat: Send gift to discord webhook
All checks were successful
Build Docker / Build Image (push) Successful in 20s
All checks were successful
Build Docker / Build Image (push) Successful in 20s
This commit is contained in:
parent
7bb07dbb9e
commit
93f45eec12
@ -22,3 +22,4 @@ docker run -d \
|
||||
| max_price | Maximum price to pay for a domain (in HNS) | 5 |
|
||||
| max_gifts_per_interval | Maximum number of gifts to send per interval | 24 |
|
||||
| interval | Interval to send gifts (in seconds) | 86400 (24 hours) |
|
||||
| discord_webhook | Discord webhook to send notifications to | None |
|
19
gift.py
19
gift.py
@ -137,6 +137,7 @@ def gift(name,email,referer, ip):
|
||||
if send_name.status_code != 200:
|
||||
return "Error sending gift:<br>" + send_name.text
|
||||
|
||||
discord(domain,email,ip,referer)
|
||||
|
||||
return True
|
||||
|
||||
@ -149,3 +150,21 @@ def balance():
|
||||
hns_balance = user_info['hns_balance']
|
||||
hns_balance = int(hns_balance)/1000000
|
||||
return hns_balance
|
||||
|
||||
def discord(domain, email,ip,referer):
|
||||
url = os.getenv('discord_webhook')
|
||||
if url == None:
|
||||
return "No webhook set"
|
||||
|
||||
payload = {
|
||||
"content": "New gift request: " + domain + "\nSent to " + email + "\nIP: " + ip + "\nReferer: " + referer
|
||||
}
|
||||
response = requests.post(url, data=json.dumps(payload), headers={'Content-Type': 'application/json'})
|
||||
|
||||
# Check if the message was sent successfully
|
||||
if response.status_code == 204:
|
||||
print("Message sent successfully!")
|
||||
else:
|
||||
print(f"Failed to send message. Status code: {response.status_code}")
|
||||
print(response.text)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user