rename file and also cleanup and try again
This commit is contained in:
22
Scripts/discord_webhook.py
Normal file
22
Scripts/discord_webhook.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import urequests as requests
|
||||
from secrets import secrets
|
||||
|
||||
def send_discord_message(message, username="Auto Garden Bot"):
|
||||
try:
|
||||
data = {
|
||||
"content": message,
|
||||
"username": username
|
||||
}
|
||||
|
||||
response = requests.post(secrets['discord_webhook_url'], json=data)
|
||||
response.raise_for_status()
|
||||
print(f"Discord message sent successfully, code {response.status_code}")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"Failed to send Discord message: {str(e)}")
|
||||
return False
|
||||
|
||||
finally:
|
||||
if 'response' in locals():
|
||||
response.close()
|
||||
Reference in New Issue
Block a user