mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2026-01-04 19:24:51 +00:00
CHanged stats interface and some fix
This commit is contained in:
parent
e1112e7a32
commit
f4eb5c42b0
6 changed files with 175 additions and 34 deletions
|
|
@ -59,7 +59,7 @@ If you want help me fixing some error in my bot, you can make pull request to th
|
||||||
| Basic Admin Feature |✔️|
|
| Basic Admin Feature |✔️|
|
||||||
| AFK Feature |✔️|
|
| AFK Feature |✔️|
|
||||||
| Downloader FB, TikTok and YT-DLP Support |✔️|
|
| Downloader FB, TikTok and YT-DLP Support |✔️|
|
||||||
| MultiLanguage Support (Still Beta) |⚠️|
|
| MultiLanguage Support (Unfinished) |⚠️|
|
||||||
| NightMode |✔️|
|
| NightMode |✔️|
|
||||||
| ChatBot based on OpenAI |✔️|
|
| ChatBot based on OpenAI |✔️|
|
||||||
| MissKaty Mata |✔️|
|
| MissKaty Mata |✔️|
|
||||||
|
|
|
||||||
BIN
assets/IronFont.otf
Normal file
BIN
assets/IronFont.otf
Normal file
Binary file not shown.
BIN
assets/statsbg.jpg
Normal file
BIN
assets/statsbg.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 63 KiB |
|
|
@ -1,5 +1,29 @@
|
||||||
|
"""
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2023 TheHamkerCat
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
"""
|
||||||
import asyncio
|
import asyncio
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
|
|
@ -56,6 +80,9 @@ __HELP__ = """
|
||||||
/unmute - Unmute A User
|
/unmute - Unmute A User
|
||||||
/ban_ghosts - Ban Deleted Accounts
|
/ban_ghosts - Ban Deleted Accounts
|
||||||
/report | @admins | @admin - Report A Message To Admins.
|
/report | @admins | @admin - Report A Message To Admins.
|
||||||
|
/set_chat_title - Change The Name Of A Group/Channel.
|
||||||
|
/set_chat_photo - Change The PFP Of A Group/Channel.
|
||||||
|
/set_user_title - Change The Administrator Title Of An Admin.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -704,3 +731,63 @@ async def report_user(self: Client, ctx: Message, strings) -> "Message":
|
||||||
continue
|
continue
|
||||||
text += f"<a href='tg://user?id={admin.user.id}>\u2063</a>"
|
text += f"<a href='tg://user?id={admin.user.id}>\u2063</a>"
|
||||||
await ctx.reply_msg(text, reply_to_message_id=ctx.reply_to_message.id)
|
await ctx.reply_msg(text, reply_to_message_id=ctx.reply_to_message.id)
|
||||||
|
|
||||||
|
|
||||||
|
@app.on_message(filters.command("set_chat_title", COMMAND_HANDLER) & ~filters.private)
|
||||||
|
@adminsOnly("can_change_info")
|
||||||
|
async def set_chat_title(self: Client, ctx: Message):
|
||||||
|
if len(ctx.command) < 2:
|
||||||
|
return await ctx.reply_text("**Usage:**\n/set_chat_title NEW NAME")
|
||||||
|
old_title = ctx.chat.title
|
||||||
|
new_title = ctx.text.split(None, 1)[1]
|
||||||
|
await ctx.chat.set_title(new_title)
|
||||||
|
await ctx.reply_text(
|
||||||
|
f"Successfully Changed Group Title From {old_title} To {new_title}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.on_message(filters.command("set_user_title", COMMAND_HANDLER) & ~filters.private)
|
||||||
|
@adminsOnly("can_change_info")
|
||||||
|
async def set_user_title(self: Client, ctx: Message):
|
||||||
|
if not ctx.reply_to_message:
|
||||||
|
return await ctx.reply_text(
|
||||||
|
"Reply to user's message to set his admin title"
|
||||||
|
)
|
||||||
|
if not ctx.reply_to_message.from_user:
|
||||||
|
return await ctx.reply_text(
|
||||||
|
"I can't change admin title of an unknown entity"
|
||||||
|
)
|
||||||
|
chat_id = ctx.chat.id
|
||||||
|
from_user = ctx.reply_to_message.from_user
|
||||||
|
if len(ctx.command) < 2:
|
||||||
|
return await ctx.reply_text(
|
||||||
|
"**Usage:**\n/set_user_title NEW ADMINISTRATOR TITLE"
|
||||||
|
)
|
||||||
|
title = ctx.text.split(None, 1)[1]
|
||||||
|
await app.set_administrator_title(chat_id, from_user.id, title)
|
||||||
|
await ctx.reply_text(
|
||||||
|
f"Successfully Changed {from_user.mention}'s Admin Title To {title}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.on_message(filters.command("set_chat_photo", COMMAND_HANDLER) & ~filters.private)
|
||||||
|
@adminsOnly("can_change_info")
|
||||||
|
async def set_chat_photo(self: Client, ctx: Message):
|
||||||
|
reply = ctx.reply_to_message
|
||||||
|
|
||||||
|
if not reply:
|
||||||
|
return await ctx.reply_text("Reply to a photo to set it as chat_photo")
|
||||||
|
|
||||||
|
file = reply.document or reply.photo
|
||||||
|
if not file:
|
||||||
|
return await ctx.reply_text(
|
||||||
|
"Reply to a photo or document to set it as chat_photo"
|
||||||
|
)
|
||||||
|
|
||||||
|
if file.file_size > 5000000:
|
||||||
|
return await ctx.reply("File size too large.")
|
||||||
|
|
||||||
|
photo = await reply.download()
|
||||||
|
await ctx.chat.set_photo(photo)
|
||||||
|
await ctx.reply_text("Successfully Changed Group Photo")
|
||||||
|
os.remove(photo)
|
||||||
|
|
@ -16,14 +16,15 @@ from database.users_chats_db import db
|
||||||
from inspect import getfullargspec
|
from inspect import getfullargspec
|
||||||
from typing import Any, Optional, Tuple
|
from typing import Any, Optional, Tuple
|
||||||
|
|
||||||
from psutil import cpu_percent
|
from psutil import cpu_percent, Process
|
||||||
from psutil import disk_usage as disk_usage_percent
|
from psutil import disk_usage as disk_usage_percent
|
||||||
from psutil import virtual_memory
|
from psutil import virtual_memory, cpu_count, boot_time, net_io_counters
|
||||||
|
|
||||||
from pyrogram import enums, filters, Client, __version__ as pyrover
|
from pyrogram import enums, filters, Client, __version__ as pyrover
|
||||||
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
|
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message, InputMediaPhoto
|
||||||
from pyrogram.raw.types import UpdateBotStopped
|
from pyrogram.raw.types import UpdateBotStopped
|
||||||
from pykeyboard import InlineKeyboard, InlineButton
|
from pykeyboard import InlineKeyboard, InlineButton
|
||||||
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
|
||||||
from misskaty import app, user, botStartTime, misskaty_version, BOT_NAME
|
from misskaty import app, user, botStartTime, misskaty_version, BOT_NAME
|
||||||
from misskaty.helper.http import http
|
from misskaty.helper.http import http
|
||||||
|
|
@ -116,32 +117,86 @@ async def server_stats(self: Client, ctx: Message) -> "Message":
|
||||||
"""
|
"""
|
||||||
Give system stats of the server.
|
Give system stats of the server.
|
||||||
"""
|
"""
|
||||||
try:
|
image = Image.open("assets/statsbg.jpg").convert("RGB")
|
||||||
serverinfo = await http.get("https://ipinfo.io/json")
|
IronFont = ImageFont.truetype("assets/IronFont.otf", 42)
|
||||||
org = serverinfo.json()["org"]
|
draw = ImageDraw.Draw(image)
|
||||||
except:
|
|
||||||
org = "N/A"
|
|
||||||
currentTime = get_readable_time(time() - botStartTime)
|
|
||||||
total, used, free = disk_usage(".")
|
|
||||||
total = get_readable_file_size(total)
|
|
||||||
used = get_readable_file_size(used)
|
|
||||||
free = get_readable_file_size(free)
|
|
||||||
neofetch = (await shell_exec("neofetch --stdout"))[0]
|
|
||||||
caption = f"""
|
|
||||||
<b>{BOT_NAME} {misskaty_version} is Up and Running successfully.</b>
|
|
||||||
<b>Bot Uptime:</b> <code>{currentTime}</code>
|
|
||||||
<b>Pyrogram Version</b>: <code>{pyrover}</code>
|
|
||||||
<b>Python Version</b>: <code>{sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]} {sys.version_info[3].title()}</code>
|
|
||||||
<b>Server:</b> <code>{org}</code>
|
|
||||||
<b>Total Disk Space:</b> <code>{total}</code>
|
|
||||||
<b>Used:</b> <code>{used}({disk_usage_percent("/").percent}%)</code>
|
|
||||||
<b>Free:</b> <code>{free}</code>
|
|
||||||
<b>CPU Usage:</b> <code>{cpu_percent()}%</code>
|
|
||||||
<b>RAM Usage:</b> <code>{virtual_memory().percent}%</code>
|
|
||||||
|
|
||||||
<code>{neofetch}</code>
|
def draw_progressbar(coordinate, progress):
|
||||||
"""
|
progress = 110 + (progress * 10.8)
|
||||||
await ctx.reply_msg(caption)
|
draw.ellipse((105, coordinate - 25, 127, coordinate), fill="#FFFFFF")
|
||||||
|
draw.rectangle((120, coordinate, progress, coordinate - 25), fill="#FFFFFF")
|
||||||
|
draw.ellipse(
|
||||||
|
(progress - 7, coordinate - 25, progress + 15, coordinate), fill="#FFFFFF"
|
||||||
|
)
|
||||||
|
|
||||||
|
total, used, free = disk_usage_percent(".")
|
||||||
|
process = Process(os.getpid())
|
||||||
|
|
||||||
|
botuptime = get_readable_time(time() - BotStartTime)
|
||||||
|
osuptime = get_readable_time(time() - boot_time())
|
||||||
|
currentTime = get_readable_time(time() - botStartTime)
|
||||||
|
botusage = f"{round(process.memory_info()[0]/1024 ** 2)} MB"
|
||||||
|
|
||||||
|
upload = get_readable_file_size(net_io_counters().bytes_sent)
|
||||||
|
download = get_readable_file_size(net_io_counters().bytes_recv)
|
||||||
|
|
||||||
|
cpu_percentage = cpu_percent()
|
||||||
|
cpu_count = cpu_count()
|
||||||
|
|
||||||
|
ram_percentage = virtual_memory().percent
|
||||||
|
ram_total = get_readable_file_size(virtual_memory().total)
|
||||||
|
ram_used = get_readable_file_size(virtual_memory().used)
|
||||||
|
|
||||||
|
disk_percenatge = disk_usage("/").percent
|
||||||
|
disk_total = get_readable_file_size(total)
|
||||||
|
disk_used = get_readable_file_size(used)
|
||||||
|
disk_free = get_readable_file_size(free)
|
||||||
|
|
||||||
|
caption = f"<b>{BOT_NAME} {misskaty_version} is Up and Running successfully.</b>**OS Uptime:** {osuptime}\n<b>Bot Uptime:</b> <code>{currentTime}</code>\n**Bot Usage:** {botusage}\n\n**Total Space:** {disk_total}\n**Free Space:** {disk_free}\n\n**Download:** {download}\n**Upload:** {upload}\n\n<b>Pyrogram Version</b>: <code>{pyrover}</code>\n<b>Python Version</b>: <code>{sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]} {sys.version_info[3].title()}</code>"
|
||||||
|
|
||||||
|
start = datetime.now()
|
||||||
|
msg = await message.reply_photo(
|
||||||
|
photo="https://te.legra.ph/file/30a82c22854971d0232c7.jpg",
|
||||||
|
caption=caption,
|
||||||
|
quote=True,
|
||||||
|
)
|
||||||
|
end = datetime.now()
|
||||||
|
|
||||||
|
draw_progressbar(243, int(cpu_percentage))
|
||||||
|
draw.text(
|
||||||
|
(225, 153),
|
||||||
|
f"( {cpu_count} core, {cpu_percentage}% )",
|
||||||
|
(255, 255, 255),
|
||||||
|
font=IronFont,
|
||||||
|
)
|
||||||
|
|
||||||
|
draw_progressbar(395, int(disk_percenatge))
|
||||||
|
draw.text(
|
||||||
|
(335, 302),
|
||||||
|
f"( {disk_used} / {disk_total}, {disk_percenatge}% )",
|
||||||
|
(255, 255, 255),
|
||||||
|
font=IronFont,
|
||||||
|
)
|
||||||
|
|
||||||
|
draw_progressbar(533, int(ram_percentage))
|
||||||
|
draw.text(
|
||||||
|
(225, 445),
|
||||||
|
f"( {ram_used} / {ram_total} , {ram_percentage}% )",
|
||||||
|
(255, 255, 255),
|
||||||
|
font=IronFont,
|
||||||
|
)
|
||||||
|
|
||||||
|
draw.text((335, 600), f"{botuptime}", (255, 255, 255), font=IronFont)
|
||||||
|
draw.text(
|
||||||
|
(857, 607),
|
||||||
|
f"{(end-start).microseconds/1000} ms",
|
||||||
|
(255, 255, 255),
|
||||||
|
font=IronFont,
|
||||||
|
)
|
||||||
|
|
||||||
|
image.save("stats.png")
|
||||||
|
await msg.edit_media(media=InputMediaPhoto("stats.png", caption=caption))
|
||||||
|
os.remove("stats.png")
|
||||||
|
|
||||||
|
|
||||||
@app.on_message(filters.command(["shell", "sh", "term"], COMMAND_HANDLER) & filters.user(SUDO))
|
@app.on_message(filters.command(["shell", "sh", "term"], COMMAND_HANDLER) & filters.user(SUDO))
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ from misskaty.helper.localization import use_chat_lang
|
||||||
from misskaty.vars import COMMAND_HANDLER, LOG_CHANNEL, FF_MPEG_NAME
|
from misskaty.vars import COMMAND_HANDLER, LOG_CHANNEL, FF_MPEG_NAME
|
||||||
|
|
||||||
LOGGER = getLogger(__name__)
|
LOGGER = getLogger(__name__)
|
||||||
regex = recompile(r"(https?://)?(www\.)?(youtube|youtu|youtube-nocookie)\.(com|be)/(watch\?v=|embed/|v/|.+\?v=)?(?P<id>[A-Za-z0-9\-=_]{11})")
|
regex = "^(https?://)?(www\.)?(youtube|youtu|youtube-nocookie)\.(com|be)/(watch\?v=|embed/|v/|.+\?v=)?(?P<id>[A-Za-z0-9\-=_]{11})"
|
||||||
YT_DB = {}
|
YT_DB = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -34,7 +34,7 @@ async def ytsearch(self: Client, ctx: Message, strings):
|
||||||
return await ctx.reply_msg(strings("no_channel"))
|
return await ctx.reply_msg(strings("no_channel"))
|
||||||
if len(ctx.command) == 1:
|
if len(ctx.command) == 1:
|
||||||
return await ctx.reply_msg(strings("no_query"))
|
return await ctx.reply_msg(strings("no_query"))
|
||||||
query = ctx.text.split(" ", maxsplit=1)[1]
|
query = ctx.text.split(" ", maxsplit=1)[1] if len(ctx.command) > 1
|
||||||
search_key = rand_key()
|
search_key = rand_key()
|
||||||
YT_DB[search_key] = query
|
YT_DB[search_key] = query
|
||||||
search = await main.VideosSearch(query).next()
|
search = await main.VideosSearch(query).next()
|
||||||
|
|
@ -60,7 +60,7 @@ async def ytsearch(self: Client, ctx: Message, strings):
|
||||||
await ctx.reply_photo(img, caption=caption, reply_markup=markup, quote=True)
|
await ctx.reply_photo(img, caption=caption, reply_markup=markup, quote=True)
|
||||||
|
|
||||||
|
|
||||||
@app.on_message(filters.command(["ytdown"], COMMAND_HANDLER))
|
@app.on_message(filters.command(["ytdown"], COMMAND_HANDLER) | filters.regex(YT_REGEX) & ~filters.channel)
|
||||||
@capture_err
|
@capture_err
|
||||||
@ratelimiter
|
@ratelimiter
|
||||||
@use_chat_lang()
|
@use_chat_lang()
|
||||||
|
|
@ -69,7 +69,7 @@ async def ytdownv2(self: Client, ctx: Message, strings):
|
||||||
return await ctx.reply_msg(strings("no_channel"))
|
return await ctx.reply_msg(strings("no_channel"))
|
||||||
if len(ctx.command) == 1:
|
if len(ctx.command) == 1:
|
||||||
return await ctx.reply_msg(strings("invalid_link"))
|
return await ctx.reply_msg(strings("invalid_link"))
|
||||||
url = ctx.input
|
url = ctx.input if len(ctx.command) > 1 else ctx.text
|
||||||
async with iYTDL(log_group_id=0, cache_path="cache", ffmpeg_location=f"/usr/bin/{FF_MPEG_NAME}") as ytdl:
|
async with iYTDL(log_group_id=0, cache_path="cache", ffmpeg_location=f"/usr/bin/{FF_MPEG_NAME}") as ytdl:
|
||||||
try:
|
try:
|
||||||
x = await ytdl.parse(url, extract=True)
|
x = await ytdl.parse(url, extract=True)
|
||||||
|
|
@ -166,7 +166,6 @@ async def ytdl_gendl_callback(self: Client, cq: CallbackQuery, strings):
|
||||||
key=key[0],
|
key=key[0],
|
||||||
downtype=media_type,
|
downtype=media_type,
|
||||||
update=cq,
|
update=cq,
|
||||||
caption_link=video_link,
|
|
||||||
)
|
)
|
||||||
except DownloadFailedError as e:
|
except DownloadFailedError as e:
|
||||||
await cq.edit_message_caption(f"Download Failed - {e}")
|
await cq.edit_message_caption(f"Download Failed - {e}")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue