forked from PratheekXD/Bot-Status-Checker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbotstatus_pratheek.py
53 lines (50 loc) · 2.5 KB
/
botstatus_pratheek.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
from pyrogram import Client, filters
from pyrogram.errors import FloodWait
import asyncio
import datetime
import pytz
import os
app = Client(
name = "botstatus_pratheek",
api_id = int(os.environ["API_ID"]),
api_hash = os.environ["API_HASH"],
session_string = os.environ["SESSION_STRING"]
)
TIME_ZONE = os.environ["TIME_ZONE"]
BOT_LIST = [i.strip() for i in os.environ.get("BOT_LIST").split(' ')]
CHANNEL_OR_GROUP_ID = int(os.environ["CHANNEL_OR_GROUP_ID"])
MESSAGE_ID = int(os.environ["MESSAGE_ID"])
BOT_ADMIN_IDS = [int(i.strip()) for i in os.environ.get("BOT_ADMIN_IDS").split(' ')]
async def main_pratheek():
async with app:
while True:
print("Checking...")
xxx_pratheek = f"📊 | 𝗟𝗜𝗩𝗘 𝗕𝗢𝗧 𝗦𝗧𝗔𝗧𝗨𝗦"
for bot in BOT_LIST:
try:
yyy_pratheek = await app.send_message(bot, "/start")
aaa = yyy_pratheek.id
await asyncio.sleep(10)
zzz_pratheek = app.get_chat_history(bot, limit = 1)
async for ccc in zzz_pratheek:
bbb = ccc.id
if aaa == bbb:
xxx_pratheek += f"\n\n🤖 @{bot}\n └ **Down** ❌"
for bot_admin_id in BOT_ADMIN_IDS:
try:
await app.send_message(int(bot_admin_id), f"🚨 **Beep! Beep!! @{bot} is down** ❌")
except Exception:
pass
await app.read_chat_history(bot)
else:
xxx_pratheek += f"\n\n🤖 @{bot}\n └ **Alive** ✅"
await app.read_chat_history(bot)
except FloodWait as e:
await asyncio.sleep(e.x)
time = datetime.datetime.now(pytz.timezone(f"{TIME_ZONE}"))
last_update = time.strftime(f"%d %b %Y at %I:%M %p")
xxx_pratheek += f"\n\n✔️ Last checked on: {last_update} ({TIME_ZONE})\n\n**♻️ Refreshes automatically - Powered By Pratheek**"
await app.edit_message_text(int(CHANNEL_OR_GROUP_ID), MESSAGE_ID, xxx_pratheek)
print(f"Last checked on: {last_update}")
await asyncio.sleep(6300)
app.run(main_pratheek())