2022-02-22 23:39:37 +00:00
|
|
|
"""
|
|
|
|
Video + Music Stream Telegram Bot
|
|
|
|
Copyright (c) 2022-present levina=lab <https://github.com/levina-lab>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but without any warranty; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/licenses.html>
|
|
|
|
"""
|
|
|
|
|
2022-01-31 12:41:47 +00:00
|
|
|
|
2022-02-25 04:08:11 +00:00
|
|
|
import os
|
2022-01-31 12:41:47 +00:00
|
|
|
import re
|
|
|
|
import uuid
|
|
|
|
import socket
|
|
|
|
import psutil
|
|
|
|
import platform
|
2022-02-22 23:39:37 +00:00
|
|
|
|
2022-01-31 12:41:47 +00:00
|
|
|
from config import BOT_USERNAME
|
2022-02-25 04:53:35 +00:00
|
|
|
|
|
|
|
from program import LOGS
|
|
|
|
from driver.core import me_bot
|
2022-01-31 12:41:47 +00:00
|
|
|
from driver.filters import command
|
2022-02-25 04:53:35 +00:00
|
|
|
from driver.utils import remove_if_exists
|
2022-01-31 12:41:47 +00:00
|
|
|
from driver.decorators import sudo_users_only, humanbytes
|
|
|
|
|
2022-02-22 23:39:37 +00:00
|
|
|
from pyrogram import Client, filters
|
2022-02-25 04:31:06 +00:00
|
|
|
from pyrogram.types import Message
|
2022-01-31 12:41:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
@Client.on_message(command(["sysinfo", f"sysinfo@{BOT_USERNAME}"]) & ~filters.edited)
|
|
|
|
@sudo_users_only
|
2022-02-25 04:31:06 +00:00
|
|
|
async def give_sysinfo(c: Client, message: Message):
|
2022-01-31 12:41:47 +00:00
|
|
|
splatform = platform.system()
|
|
|
|
platform_release = platform.release()
|
|
|
|
platform_version = platform.version()
|
|
|
|
architecture = platform.machine()
|
|
|
|
hostname = socket.gethostname()
|
|
|
|
ip_address = socket.gethostbyname(socket.gethostname())
|
|
|
|
mac_address = ":".join(re.findall("..", "%012x" % uuid.getnode()))
|
|
|
|
processor = platform.processor()
|
|
|
|
ram = humanbytes(round(psutil.virtual_memory().total))
|
|
|
|
cpu_freq = psutil.cpu_freq().current
|
|
|
|
if cpu_freq >= 1000:
|
|
|
|
cpu_freq = f"{round(cpu_freq / 1000, 2)}GHz"
|
|
|
|
else:
|
|
|
|
cpu_freq = f"{round(cpu_freq, 2)}MHz"
|
|
|
|
du = psutil.disk_usage(client.workdir)
|
|
|
|
psutil.disk_io_counters()
|
|
|
|
disk = f"{humanbytes(du.used)} / {humanbytes(du.total)} " f"({du.percent}%)"
|
|
|
|
cpu_len = len(psutil.Process().cpu_affinity())
|
|
|
|
somsg = f"""🖥 **System Information**
|
|
|
|
|
|
|
|
**PlatForm :** `{splatform}`
|
|
|
|
**PlatForm - Release :** `{platform_release}`
|
|
|
|
**PlatForm - Version :** `{platform_version}`
|
|
|
|
**Architecture :** `{architecture}`
|
|
|
|
**HostName :** `{hostname}`
|
|
|
|
**IP :** `{ip_address}`
|
|
|
|
**Mac :** `{mac_address}`
|
|
|
|
**Processor :** `{processor}`
|
|
|
|
**Ram : ** `{ram}`
|
|
|
|
**CPU :** `{cpu_len}`
|
|
|
|
**CPU FREQ :** `{cpu_freq}`
|
|
|
|
**DISK :** `{disk}`
|
|
|
|
"""
|
|
|
|
await message.reply(somsg)
|
2022-02-25 04:08:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
@Client.on_message(command(["logs", f"logs@{BOT_USERNAME}"]) & ~filters.edited)
|
|
|
|
@sudo_users_only
|
|
|
|
async def get_bot_logs(c: Client, m: Message):
|
2022-02-25 04:53:35 +00:00
|
|
|
id = me_bot.id
|
|
|
|
bot_log_path = f'streambot-logs-{id}.txt'
|
2022-02-25 04:08:11 +00:00
|
|
|
if os.path.exists(bot_log_path):
|
|
|
|
try:
|
|
|
|
await m.reply_document(
|
|
|
|
bot_log_path,
|
|
|
|
quote=True,
|
|
|
|
caption='📄 This is the bot logs',
|
|
|
|
)
|
2022-02-25 04:53:35 +00:00
|
|
|
remove_if_exists(bot_log_path)
|
|
|
|
except BaseException as err:
|
|
|
|
LOGS.info(f'[ERROR]: {err}')
|
2022-02-25 04:08:11 +00:00
|
|
|
if not os.path.exists(bot_log_path):
|
|
|
|
await m.reply_text('❌ no logs found !')
|