-
Notifications
You must be signed in to change notification settings - Fork 22
/
alive.py
60 lines (46 loc) · 1.8 KB
/
alive.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
from pyrogram import Client, filters
from pyrogram.types import Message
from utils.misc import modules_help, requirements_list, prefix
import asyncio
import time
from datetime import datetime
from sys import version_info
from pyrogram import __version__ as __pyro_version__
StartTime = time.time()
__major__ = 0
__minor__ = 2
__micro__ = 1
__python_version__ = f"{version_info[0]}.{version_info[1]}.{version_info[2]}"
def get_readable_time(seconds: int) -> str:
count = 0
ping_time = ""
time_list = []
time_suffix_list = ["s", "m", "h", "days"]
while count < 4:
count += 1
remainder, result = divmod(seconds, 60) if count < 3 else divmod(seconds, 24)
if seconds == 0 and remainder == 0:
break
time_list.append(int(result))
seconds = int(remainder)
for x in range(len(time_list)):
time_list[x] = str(time_list[x]) + time_suffix_list[x]
if len(time_list) == 4:
ping_time += time_list.pop() + ", "
time_list.reverse()
ping_time += ":".join(time_list)
return ping_time
@Client.on_message(filters.command("alive", prefix) & filters.me)
async def alive(client, message):
start_time = time.time()
uptime = get_readable_time((time.time() - StartTime))
reply_msg = f"!<a href = https://github.com/Dragon-Userbot>Dragon-Userbot</a>\n"
reply_msg += f"<b>Python Version:</b> <code>{__python_version__}</code>\n"
reply_msg += f"<b>Pyrogram Version:</b> <code>{__pyro_version__}</code>\n"
end_time = time.time()
reply_msg += f"\nUptime: <code>{uptime}</code>"
await message.delete()
await client.send_message(message.chat.id, reply_msg, disable_web_page_preview=True)
modules_help["alive"] = {
"alive": " check bot alive status",
}