-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebfunc.py
More file actions
52 lines (46 loc) · 1.34 KB
/
Webfunc.py
File metadata and controls
52 lines (46 loc) · 1.34 KB
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
import requests
import time
import os
from threading import Thread
#https://alfred-discord-bot.yashvardhan13.repl.co
def check():
a = requests.get("https://alfred-discord-bot.yashvardhan13.repl.co")
if a.status_code > 300:
return False
return True
def t():
while True:
try:
if not check():
send_message("Alfred is having a downtime.")
time.sleep(30)
except:
print("Alfred request error")
def self_check():
while True:
try:
time.sleep(30)
r = requests.get("https://suicide-detector-api-1.yashvardhan13.repl.co/")
if r.status_code>300:
os.system("busybox reboot")
except:
print("Self Check error")
def send_message(message, color=16742520):
json={
'embeds':[
{
'title':"Server",
'description':message,
'color': color
}
]
}
requests.post( "https://discord.com/api/webhooks/978532333332344862/n47VPtIj1MX7na_EmUn_v7qLWhZ8rAOwDeDIb3RHcsfO05TF8gin_7ZBErboqEDdSvM0", json=json)
if check():
send_message("Alfred's server is online", color=3066993)
else:
send_message("Alfred's server is offline")
th = Thread(target = t)
th.start()
th1 = Thread(target = self_check)
th1.start()