From 05390ac6459b4994ed515ff85664f5f5cfbb3655 Mon Sep 17 00:00:00 2001 From: yasir Date: Sun, 12 Mar 2023 21:34:01 +0700 Subject: [PATCH] Minor Fix --- misskaty/__init__.py | 2 +- misskaty/plugins/admin.py | 60 ++++++++++++++---------------- misskaty/plugins/chatbot_ai.py | 2 +- misskaty/plugins/dev.py | 2 +- misskaty/plugins/filter_request.py | 3 ++ misskaty/plugins/genss.py | 3 +- misskaty/plugins/grup_tools.py | 10 ++--- misskaty/plugins/mediainfo.py | 3 +- misskaty/plugins/sub_extractor.py | 26 ++++++------- 9 files changed, 54 insertions(+), 57 deletions(-) diff --git a/misskaty/__init__.py b/misskaty/__init__.py index 337db9ef..b397f1c5 100644 --- a/misskaty/__init__.py +++ b/misskaty/__init__.py @@ -19,7 +19,7 @@ basicConfig( getLogger("pyrogram").setLevel(ERROR) MOD_LOAD = [] -MOD_NOLOAD = [] +MOD_NOLOAD = ["subscene_dl"] HELPABLE = {} cleanmode = {} botStartTime = time.time() diff --git a/misskaty/plugins/admin.py b/misskaty/plugins/admin.py index e0aa80f4..6de27bba 100644 --- a/misskaty/plugins/admin.py +++ b/misskaty/plugins/admin.py @@ -5,7 +5,7 @@ from time import time from pyrogram import enums, filters from pyrogram.errors import ChatAdminRequired, FloodWait -from pyrogram.types import ChatPermissions +from pyrogram.types import ChatPermissions, ChatPrivileges from database.warn_db import add_warn, get_warn, remove_warns from misskaty import app @@ -143,9 +143,9 @@ async def kickFunc(client, message): return await message.reply_text("Wow, you wanna kick my owner?") if user_id in (await list_admins(message.chat.id)): return await message.reply_text("Lol, it's crazy if i can kick an admin.") - mention = (await app.get_users(user_id)).mention + user = await app.get_users(user_id) msg = f""" -**Kicked User:** {mention} +**Kicked User:** {user.mention} [{user.id}] **Kicked By:** {message.from_user.mention if message.from_user else 'Anon'} **Reason:** {reason or '-'}""" if message.command[0][0] == "d": @@ -372,35 +372,39 @@ async def promoteFunc(client, message): return await message.reply_text("I don't have enough permissions") if message.command[0][0] == "f": await message.chat.promote_member( - user_id=user_id, - can_change_info=bot.can_change_info, - can_invite_users=bot.can_invite_users, - can_delete_messages=bot.can_delete_messages, - can_restrict_members=bot.can_restrict_members, - can_pin_messages=bot.can_pin_messages, - can_promote_members=bot.can_promote_members, - can_manage_chat=bot.can_manage_chat, - can_manage_voice_chats=bot.can_manage_voice_chats, + user_id, + ChatPrivileges( + can_change_info=bot.can_change_info, + can_invite_users=bot.can_invite_users, + can_delete_messages=bot.can_delete_messages, + can_restrict_members=bot.can_restrict_members, + can_pin_messages=bot.can_pin_messages, + can_promote_members=bot.can_promote_members, + can_manage_chat=bot.can_manage_chat, + can_manage_voice_chats=bot.can_manage_voice_chats + ) ) return await message.reply_text(f"Fully Promoted! {umention}") await message.chat.promote_member( - user_id=user_id, - can_change_info=False, - can_invite_users=bot.can_invite_users, - can_delete_messages=bot.can_delete_messages, - can_restrict_members=False, - can_pin_messages=False, - can_promote_members=False, - can_manage_chat=bot.can_manage_chat, - can_manage_voice_chats=bot.can_manage_voice_chats, + user_id, + ChatPrivileges( + can_change_info=False, + can_invite_users=bot.can_invite_users, + can_delete_messages=bot.can_delete_messages, + can_restrict_members=False, + can_pin_messages=False, + can_promote_members=False, + can_manage_chat=bot.can_manage_chat, + can_manage_voice_chats=bot.can_manage_voice_chats + ) ) await message.reply_text(f"Promoted! {umention}") # Demote Member @app.on_message(filters.command("demote", COMMAND_HANDLER) & filters.group) -@adminsOnly("can_promote_members") +@adminsOnly("can_restrict_members") @ratelimiter async def demote(client, message): if not message.from_user: @@ -412,16 +416,8 @@ async def demote(client, message): return await message.reply_text("I can't demote myself.") if user_id in SUDO: return await message.reply_text("You wanna demote the elevated one?") - await message.chat.promote_member( - user_id=user_id, - can_change_info=False, - can_invite_users=False, - can_delete_messages=False, - can_restrict_members=False, - can_pin_messages=False, - can_promote_members=False, - can_manage_chat=False, - can_manage_voice_chats=False, + await message.chat.demote_member( + user_id=user_id ) umention = (await app.get_users(user_id)).mention await message.reply_text(f"Demoted! {umention}") diff --git a/misskaty/plugins/chatbot_ai.py b/misskaty/plugins/chatbot_ai.py index 2821e02e..6c82de48 100644 --- a/misskaty/plugins/chatbot_ai.py +++ b/misskaty/plugins/chatbot_ai.py @@ -12,7 +12,7 @@ from misskaty.vars import COMMAND_HANDLER, OPENAI_API @ratelimiter async def chatbot(c, m): if len(m.command) == 1: - return await kirimPesan(m, f"Gunakan perintah /{m.command[0]} [pertanyaan] untuk menanyakan pertanyaan menggunakan AI.") + return await kirimPesan(m, f"Please use command /{m.command[0]} [question] to ask your question.") pertanyaan = m.text.split(" ", maxsplit=1)[1] headers = { "Content-Type": "application/json", diff --git a/misskaty/plugins/dev.py b/misskaty/plugins/dev.py index d05cf36f..e64c8cb7 100644 --- a/misskaty/plugins/dev.py +++ b/misskaty/plugins/dev.py @@ -146,7 +146,7 @@ async def evaluation_cmd_t(_, m): if (m.command and len(m.command) == 1) or m.text == "app.run()": return await edit_or_reply(m, text="__No evaluate message!__") cmd = m.text.split(" ", 1)[1] if m.command else m.text.split("app.run()")[0] - status_message = await editPesan(m, "Processing eval pyrogram..") if m.from_user.is_self else await kirimPesan(m, "Processing eval pyrogram..") + status_message = await editPesan(m, "Processing eval pyrogram..") if m.from_user.is_self else await kirimPesan(m, "Processing eval pyrogram..", quote=True) old_stderr = sys.stderr old_stdout = sys.stdout diff --git a/misskaty/plugins/filter_request.py b/misskaty/plugins/filter_request.py index ef4fa182..75f93baa 100644 --- a/misskaty/plugins/filter_request.py +++ b/misskaty/plugins/filter_request.py @@ -10,6 +10,7 @@ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup from misskaty import app from .web_scraper import SCRAP_DICT, data_kuso from .pypi_search import PYPI_DICT +from misskaty.core.decorator.permissions import admins_in_chat from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.core.decorator.errors import capture_err from misskaty.helper.time_gap import check_time_gap @@ -114,9 +115,11 @@ async def clear_reqdict(): data_kuso.clear() REQUEST_DB.clear() PYPI_DICT.clear() + admins_in_chat.clear() try: os.rmdir("downloads") os.remove("MissKatyLogs.txt") + os.rmdir("GenSS") open("MissKatyLogs.txt", "w").close() except: pass diff --git a/misskaty/plugins/genss.py b/misskaty/plugins/genss.py index 73e129ee..f5b7155a 100644 --- a/misskaty/plugins/genss.py +++ b/misskaty/plugins/genss.py @@ -51,7 +51,8 @@ async def genss(client, m): if media is None: return await kirimPesan(m, "Reply to a Telegram Video or document as video to generate screenshoot!", quote=True) process = await kirimPesan(m, "Processing, please wait..", quote=True) - + if media.file_size > 2097152000: + return await kirimPesan(m, "Sorry, download limited to 2GB to reduce flood. You can convert your files to link.") c_time = time.time() dl = await replied.download( file_name="/downloads/", diff --git a/misskaty/plugins/grup_tools.py b/misskaty/plugins/grup_tools.py index 0301c8ef..a6cee5cc 100644 --- a/misskaty/plugins/grup_tools.py +++ b/misskaty/plugins/grup_tools.py @@ -47,14 +47,14 @@ def draw_multiple_line_text(image, text, font, text_start_height): @asyncify -def welcomepic(pic, user, chat, count, id): +def welcomepic(pic, user, chat, id): background = Image.open("img/bg.png") # <- Background Image (Should be PNG) background = background.resize((1024, 500), Image.ANTIALIAS) pfp = Image.open(pic).convert("RGBA") pfp = circle(pfp) pfp = pfp.resize((265, 265)) # Resizes the Profilepicture so it fits perfectly in the circle font = ImageFont.truetype("Calistoga-Regular.ttf", 37) # <- Text Font of the Member Count. Change the text size for your preference - member_text = f"User#{count}, Selamat Datang {user}" # <- Text under the Profilepicture with the Membercount + member_text = f"Selamat Datang {user} [{id}]" # <- Text under the Profilepicture with the Membercount draw_multiple_line_text(background, member_text, font, 395) draw_multiple_line_text(background, chat, font, 47) ImageDraw.Draw(background).text( @@ -93,13 +93,12 @@ async def member_has_joined(c: app, member: ChatMemberUpdated): first_name = f"{user.first_name} {user.last_name}" if user.last_name else user.first_name id = user.id dc = user.dc_id or "Member tanpa PP" - count = await app.get_chat_members_count(member.chat.id) try: pic = await app.download_media(user.photo.big_file_id, file_name=f"pp{user.id}.png") except AttributeError: pic = "img/profilepic.png" try: - welcomeimg = await welcomepic(pic, user.first_name, member.chat.title, count, user.id) + welcomeimg = await welcomepic(pic, user.first_name, member.chat.title, user.id) temp.MELCOW[f"welcome-{member.chat.id}"] = await c.send_photo( member.chat.id, photo=welcomeimg, @@ -175,7 +174,6 @@ async def save_group(bot, message): ) else: for u in message.new_chat_members: - count = await app.get_chat_members_count(message.chat.id) try: pic = await app.download_media(u.photo.big_file_id, file_name=f"pp{u.id}.png") except AttributeError: @@ -186,7 +184,7 @@ async def save_group(bot, message): except: pass try: - welcomeimg = await welcomepic(pic, u.first_name, message.chat.title, count, u.id) + welcomeimg = await welcomepic(pic, u.first_name, message.chat.title, u.id) temp.MELCOW[f"welcome-{message.chat.id}"] = await app.send_photo( message.chat.id, photo=welcomeimg, diff --git a/misskaty/plugins/mediainfo.py b/misskaty/plugins/mediainfo.py index 4badc5fe..4a614374 100644 --- a/misskaty/plugins/mediainfo.py +++ b/misskaty/plugins/mediainfo.py @@ -32,7 +32,8 @@ async def mediainfo(client, message): file_info = get_file_id(message.reply_to_message) if file_info is None: return await editPesan(process, "Please reply to valid media.") - + if (message.reply_to_message.video and message.reply_to_message.video.file_size > 2097152000) or (message.reply_to_message.document and message.reply_to_message.document.file_size > 2097152000): + return await editPesan(process, "Sorry, download limited to 2GB to reduce flood. You can convert your files to link.") c_time = time.time() dl = await message.reply_to_message.download( file_name="/downloads/", diff --git a/misskaty/plugins/sub_extractor.py b/misskaty/plugins/sub_extractor.py index 41056c47..6234c9c5 100644 --- a/misskaty/plugins/sub_extractor.py +++ b/misskaty/plugins/sub_extractor.py @@ -148,17 +148,17 @@ async def stream_extract(bot, update): except: return await update.answer("⚠️ DONT DELETE YOUR MESSAGE!", True) await editPesan(update.message, "⏳ Processing...") + if codec == "aac": + format = "aac" + elif codec == "mp3": + format = "mp3" + elif codec == "eac3": + format = "eac3" + else: + format = "srt" + start_time = perf_counter() + namafile = get_subname(lang, link, format) try: - if codec == "aac": - format = "aac" - elif codec == "mp3": - format = "mp3" - elif codec == "eac3": - format = "eac3" - else: - format = "srt" - start_time = perf_counter() - namafile = get_subname(lang, link, format) LOGGER.info(f"ExtractSub: {namafile} by {update.from_user.first_name} [{update.from_user.id}]") (await shell_exec(f"mediaextract -i {link} -map {map} '{namafile}'"))[0] end_time = perf_counter() @@ -173,9 +173,7 @@ async def stream_extract(bot, update): progress_args=("Uploading files..", update.message, c_time), ) await hapusPesan(update.message) - try: - os.remove(namafile) - except: - pass + os.remove(namafile) except Exception as e: + os.remove(namafile) await editPesan(update.message, f"Failed extract sub, Maybe unsupported format..\n\nLink: {link}\nERR: {e}")