-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
105 lines (89 loc) · 4.59 KB
/
main.py
File metadata and controls
105 lines (89 loc) · 4.59 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
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
import os
import time
import datetime
import requests
import pyrogram
user_session_string = os.environ.get("user_session_string")
bots = [i.strip() for i in os.environ.get("bots").split(' ')]
bot_owner = os.environ.get("bot_owner")
update_channel = os.environ.get("update_channel")
status_message_id = int(os.environ.get("status_message_id"))
api_id = int(os.environ.get("api_id"))
api_hash = os.environ.get("api_hash")
user_client = pyrogram.Client(
user_session_string, api_id=api_id, api_hash=api_hash)
api_url = 'http://botsuniverse.live'
api_url2 = 'http://api-bu-v2.herokuapp.com'
api_url3 = 'http://apibu.herokuapp.com'
er = requests.get(api_url)
ew = requests.get(api_url2)
eww = requests.get(api_url3)
op = er.status_code
yu = ew.status_code
oo = eww.status_code
def main():
with user_client:
while True:
print("[INFO] starting to check uptime..")
edit_text = f"Our Bot's List & Their Status:\n\nNote: All Bot Status will Be Auto Checked\nIn 4 Hours"
user_client.send_message(bot_owner, f'Starting To Check Bots..')
user_client.send_message(-1001482059289, f'Starting To Check Bots..')
for bot in bots:
print(f"[INFO] checking @{bot}")
msg = (f"[INFO] checking @{bot}")
user_client.send_message(-1001482059289, msg)
snt = user_client.send_message(bot, '/start')
time.sleep(30)
msg = user_client.get_history(bot, 1)[0]
if snt.message_id == msg.message_id:
print(f"[WARNING] @{bot} is down")
jio = (f"[WARNING] @{bot} is down")
user_client.send_message(-1001482059289, jio)
edit_text += f"💔 @{bot} AVAILABLITY: Not Avaliable\n\n"
user_client.send_message(bot_owner,
f"💤 @{bot} Available: Nope..")
else:
print(f"[INFO] all good with @{bot}")
kya = f"[INFO] all good with @{bot}"
user_client.send_message(-1001482059289, kya)
edit_text += f"❤ @{bot} AVAILABLITY: Yesh\n\n"
user_client.read_history(bot)
utc_now = datetime.datetime.utcnow()
ist_now = utc_now + datetime.timedelta(minutes=30, hours=5)
edit_text += f"__last checked on \n{str(utc_now)} UTC\n{ist_now} IST__"
user_client.edit_message_text(update_channel, status_message_id,
edit_text)
print(f"[INFO] everything done! sleeping for 4 Hours")
if op != 200:
user_client.send_message(bot_owner,
f"💤[Api Bu]({api_url}) Available: Nope..",
parse_mode="md")
# Tell If Alive?
else:
user_client.send_message(bot_owner,
f"❤ [Api Bu]({api_url}) Available: Yesh...",
disable_web_page_preview=True,
parse_mode="md")
if yu != 200:
user_client.send_message(bot_owner,
f"💤[Api Bu V2]({api_url2}) Available: Nope..",
disable_web_page_preview=True,
parse_mode="md")
else:
user_client.send_message(bot_owner,
f"❤ [Api Bu V2]({api_url2}) Available: Yesh...",
disable_web_page_preview=True,
parse_mode="md")
if oo != 200:
user_client.send_message(bot_owner,
f"💤[Bots Universe Website]({api_url3}) Available: Nope..",
disable_web_page_preview=True,
parse_mode="md")
else:
user_client.send_message(bot_owner,
f"❤ [Bots Universe Website]({api_url3}) Available: Yesh...",
disable_web_page_preview=True,
parse_mode="md")
user_client.send_message(bot_owner, f'Everything Done..\nNext Check Is After Four Hour')
time.sleep(120 * 120)
main()