-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpost_to_discord.py
48 lines (46 loc) · 1.81 KB
/
post_to_discord.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import requests
import os
import json
def send(data):
url = os.getenv("DISCORD_WEBHOOK_URL")
payload={
"username": "TNB Explorer",
"avatar_url": "https://itsnikhil.github.io/tnb-analysis/web/assets/maskable_icon.png",
"embeds": [
{
"title": "TNB Analysis summary " + data["Date"],
"url": "https://tnbexplorer.com/tnb/stats",
"description": "Daily dose of insights about thenewboston digital crypto currency network analysis like total coins distributed, richest account, wealth distribution, etc.",
"fields": [
{
"name": "Total coins distributed",
"value": "{:,}".format(int(data["Total"]))
},
{
"name": "Total accounts",
"value": str(data["Accounts"])
},
{
"name": "Coins released past 24hr",
"value": "{:,}".format(int(data["Shift"]))
},
{
"name": "Richest account balance",
"value": "{:,}".format(int(data["Max balance"]))
}
],
"image": {
"url": "https://itsnikhil.github.io/tnb-analysis/screenshots/Daily-change-in-coins.png"
},
"footer": {
"text": "visit website for further information like charts and rich list"
}
}
]
}
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
if response.status_code != 204:
raise Exception(response.text)