-
Notifications
You must be signed in to change notification settings - Fork 1
/
BotStatus.py
60 lines (55 loc) · 3.05 KB
/
BotStatus.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
# Copyright ©️ 2021 IDN-C-X. All Rights Reserved
# You are free to use this code in any of your project, but you must include the following in your README.md (Copy & paste)
# Changing the code is not allowed! Read GNU AFFERO GENERAL PUBLIC LICENSE: https://github.com/teletips/PowerfulBotStatus/blob/main/LICENSE
from pyrogram import Client, filters
from pyrogram.errors import FloodWait
import asyncio
import datetime
import pytz
import os
app = Client(
api_id = int(os.environ["API_ID"]),
api_hash = os.environ["API_HASH"],
session_name = os.environ["SESSION_NAME"]
)
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_idncoder():
async with app:
while True:
print("Checking The System...")
GET_CHANNEL_OR_GROUP = await app.get_chat(int(CHANNEL_OR_GROUP_ID))
CHANNEL_OR_GROUP_NAME = GET_CHANNEL_OR_GROUP.title
CHANNEL_OR_GROUP_TYPE = GET_CHANNEL_OR_GROUP.type
xxx_idncoder = f"📊 **<u>LIVE BOT STATUS</u>**\n\n**💬 {CHANNEL_OR_GROUP_TYPE}**: {CHANNEL_OR_GROUP_NAME}"
for bot in BOT_LIST:
try:
yyy_idncoder = await app.send_message(bot, "/start")
aaa = yyy_idncoder.message_id
await asyncio.sleep(7)
zzz_idncoder = await app.get_history(bot, limit = 1)
for ccc in zzz_idncoder:
bbb = ccc.message_id
if aaa == bbb:
xxx_idncoder += f"\n\n🤖 **BOT**: @{bot}\n🔴 **STATUS**: 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_history(bot)
else:
xxx_idncoder += f"\n\n🤖 **BOT**: @{bot}\n🟢 **STATUS**: Alive ✅"
await app.read_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_idncoder += f"\n\n✔️ Last checked on: {last_update} ({TIME_ZONE})\n\n<i>♻️ Updates every 45 minutes - Powered By @IDNCoderX</i>"
await app.edit_message_text(int(CHANNEL_OR_GROUP_ID), MESSAGE_ID, xxx_teletips)
print(f"Last checked on: {last_update}")
await asyncio.sleep(1500)
app.run(main_idncoder())