-
Notifications
You must be signed in to change notification settings - Fork 7
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
0783ee9
commit f406b39
Showing
4 changed files
with
49 additions
and
1 deletion.
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
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
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
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,45 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"net/http" | ||
"time" | ||
) | ||
|
||
func sendWebhook() { | ||
if config.DiscordWebhook != "" { | ||
data := map[string]any{ | ||
"username": "Forecast Bot", | ||
"content": "Weather Data has been updated!", | ||
"avatar_url": "https://rc24.xyz/images/logo-small.png", | ||
"attachments": []map[string]any{ | ||
{ | ||
"fallback": "Weather Data Update", | ||
"color": "#0381D7", | ||
"author_name": "RiiConnect24 Forecast Script", | ||
"author_icon": "https://rc24.xyz/images/webhooks/forecast/profile.png", | ||
"text": "Weather Data has been updated!", | ||
"title": "Update!", | ||
"fields": []map[string]any{ | ||
{ | ||
"title": "Script", | ||
"value": "Forecast Channel", | ||
"short": false, | ||
}, | ||
}, | ||
"thumb_url": "https://rc24.xyz/images/webhooks/forecast/accuweather.png", | ||
"footer": "RiiConnect24 Script", | ||
"footer_icon": "https://rc24.xyz/images/logo-small.png", | ||
"ts": int(time.Now().Unix()), | ||
}, | ||
}, | ||
} | ||
|
||
_bytes, err := json.Marshal(data) | ||
checkError(err) | ||
|
||
_, err = http.Post(config.DiscordWebhook, "application/json", bytes.NewReader(_bytes)) | ||
checkError(err) | ||
} | ||
} |