-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsysinfo.py
More file actions
51 lines (43 loc) · 1.5 KB
/
sysinfo.py
File metadata and controls
51 lines (43 loc) · 1.5 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
# -*- coding: utf-8 -*-
# Coded by @maxunof with power of Senko!
import platform
import time
from git import Repo
from telethon import __version__
from .. import const, sdk
class Module(sdk.Module):
def __init__(self):
self.name: str = "System Information"
self.init_time: float = time.time()
def get_distribution(self) -> str:
try:
with open("/etc/os-release") as file:
for line in file:
key, val = line.rstrip().split("=")
if key == "NAME":
return val.strip('"')
except:
pass
return None
async def info_cmd(self, event: sdk.Event, command: sdk.Command):
_os = platform.system()
commit = None
try:
commit = str(Repo(const.ROOT_DIRECTORY).commit("main"))[:10]
except:
pass
info = [
f"<b>• {key}</b>: <code>{value}</code>"
for key, value in {
"OS": _os,
"Release": platform.release(),
"Distribution": (self.get_distribution() if _os == "Linux" else None),
"Arch": platform.machine(),
"Python": platform.python_version(),
"Telethon": __version__,
"Commit": commit,
"Uptime": sdk.format_seconds(time.time() - self.init_time),
}.items()
if value
]
await sdk.send(event.message, "<b>System Info:</b>\n\n" + "\n".join(info))