-
Notifications
You must be signed in to change notification settings - Fork 1
/
input_validation.py
55 lines (50 loc) · 1.48 KB
/
input_validation.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
import requests
from time import sleep
import json
import sys
# getting the tubehosting auth_token via /login
def get_auth_token(email, password):
post_data = {
"mail": email,
"password": password
}
response = requests.post("https://api.tube-hosting.com/login", json=post_data)
# converting JSON
response_list = json.loads(response.text)
# returning token
return response_list['token']
# validates user input
def validate(email, password, webhook_url):
# validates login data
try:
get_auth_token(email, password)
except:
print("Wrong login data")
print("Shutting down")
sleep(5)
sys.exit(1)
# testing the webhook
data = {
"content": "",
"embeds": [
{
"title": "This is a test Message",
"description": "Your webhook works",
"color": 10751,
"footer": {
"text": "tubehosting ddos alert\nmade with <3 by Lennart01"
}
}
],
"username": "DDoS-Alert",
"avatar_url": "https://resources.tube-hosting.com/logo/app_icon.png"
}
try:
response = requests.post(webhook_url, json=data)
if response.status_code != 204:
raise ValueError('Wrong webhook')
except:
print("Webhook is incorrect")
print("Shutting down")
sleep(5)
sys.exit(1)