diff --git a/misskaty/core/decorator/permissions.py b/misskaty/core/decorator/permissions.py index b8317368..e5d242fd 100644 --- a/misskaty/core/decorator/permissions.py +++ b/misskaty/core/decorator/permissions.py @@ -19,10 +19,10 @@ from ...helper.localization import ( ) -async def member_permissions(chat_id: int, user_id: int, client): +async def member_permissions(chat_id: int, user_id: int): perms = [] try: - member = (await client.get_chat_member(chat_id, user_id)).privileges + member = (await app.get_chat_member(chat_id, user_id)).privileges if member.can_post_messages: perms.append("can_post_messages") if member.can_edit_messages: @@ -164,7 +164,7 @@ def adminsOnly(permission): return await unauthorised(message, permission, subFunc2) # For admins and sudo users userID = message.from_user.id - permissions = await member_permissions(chatID, userID, client) + permissions = await member_permissions(chatID, userID) if userID not in SUDO and permission not in permissions: return await unauthorised(message, permission, subFunc2) return await authorised(func, subFunc2, client, message, *args, **kwargs) diff --git a/misskaty/plugins/admin.py b/misskaty/plugins/admin.py index 80495539..780216f7 100644 --- a/misskaty/plugins/admin.py +++ b/misskaty/plugins/admin.py @@ -634,10 +634,10 @@ async def warn_user(client, message, strings): @app.on_callback_query(filters.regex("unwarn_")) @use_chat_lang() -async def remove_warning(client, cq, strings): +async def remove_warning(_, cq, strings): from_user = cq.from_user chat_id = cq.message.chat.id - permissions = await member_permissions(chat_id, from_user.id, client) + permissions = await member_permissions(chat_id, from_user.id) permission = "can_restrict_members" if permission not in permissions: return await cq.answer( @@ -664,10 +664,10 @@ async def remove_warning(client, cq, strings): @app.on_callback_query(filters.regex("unmute_")) @use_chat_lang() -async def unmute_user(client, cq, strings): +async def unmute_user(_, cq, strings): from_user = cq.from_user chat_id = cq.message.chat.id - permissions = await member_permissions(chat_id, from_user.id, client) + permissions = await member_permissions(chat_id, from_user.id) permission = "can_restrict_members" if permission not in permissions: return await cq.answer( @@ -687,10 +687,10 @@ async def unmute_user(client, cq, strings): @app.on_callback_query(filters.regex("unban_")) @use_chat_lang() -async def unban_user(client, cq, strings): +async def unban_user(_, cq, strings): from_user = cq.from_user chat_id = cq.message.chat.id - permissions = await member_permissions(chat_id, from_user.id, client) + permissions = await member_permissions(chat_id, from_user.id) permission = "can_restrict_members" if permission not in permissions: return await cq.answer( diff --git a/misskaty/plugins/dev.py b/misskaty/plugins/dev.py index c0780c94..8469436b 100644 --- a/misskaty/plugins/dev.py +++ b/misskaty/plugins/dev.py @@ -29,7 +29,7 @@ from psutil import net_io_counters, virtual_memory from pyrogram import Client from pyrogram import __version__ as pyrover from pyrogram import enums, filters -from pyrogram.errors import ChatSendPhotosForbidden, FloodWait, MessageTooLong, PeerIdInvalid, ChatSendPlainForbidden +from pyrogram.errors import ChatSendPhotosForbidden, FloodWait, MessageTooLong, PeerIdInvalid, ChatSendPlainForbidden, ReactionInvalid from pyrogram.raw.types import UpdateBotStopped from pyrogram.types import ( InlineKeyboardButton, @@ -126,6 +126,10 @@ async def log_file(_, ctx: Message, strings): @app.on_message(filters.command(["donate"], COMMAND_HANDLER)) async def donate(self: Client, ctx: Message): + try: + await ctx.react(emoji="❤️") + except ReactionInvalid: + pass try: await ctx.reply_photo( "https://img.yasirweb.eu.org/file/9427d61d6968b8ee4fb2f.jpg", diff --git a/misskaty/plugins/federation.py b/misskaty/plugins/federation.py index 53d70b3f..e1c918ec 100644 --- a/misskaty/plugins/federation.py +++ b/misskaty/plugins/federation.py @@ -35,7 +35,7 @@ from pyrogram.enums import ChatMemberStatus, ChatType, ParseMode from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup from misskaty.helper.functions import extract_user, extract_user_and_reason -from pyrogram.errors import FloodWait +from pyrogram.errors import FloodWait, PeerIdInvalid from misskaty.core.decorator.errors import capture_err __MODULE__ = "Federation" @@ -55,11 +55,11 @@ async def new_fed(self, message): chat = message.chat user = message.from_user if message.chat.type != ChatType.PRIVATE: - return await message.reply_text( + return await message.reply_msg( "Federations can only be created by privately messaging me." ) if len(message.command) < 2: - return await message.reply_text("Please write the name of the federation!") + return await message.reply_msg("Please write the name of the federation!") fednam = message.text.split(None, 1)[1] if not fednam == "": fed_id = str(uuid.uuid4()) @@ -80,11 +80,11 @@ async def new_fed(self, message): upsert=True, ) if not x: - return await message.reply_text( + return await message.reply_msg( f"Can't federate! Please contact {SUPPORT_CHAT} if the problem persist." ) - await message.reply_text( + await message.reply_msg( "**You have succeeded in creating a new federation!**" "\nName: `{}`" "\nID: `{}`" @@ -597,8 +597,7 @@ async def fban_user(client, message): chat = message.chat from_user = message.from_user if message.chat.type == ChatType.PRIVATE: - await message.reply_text("This command is specific to groups, not our pm!.") - return + return await message.reply_text("This command is specific to groups, not our pm!.") fed_id = await get_fed_id(chat.id) if not fed_id: return await message.reply_text("**This chat is not a part of any federation.") @@ -617,7 +616,10 @@ async def fban_user(client, message): "**You needed to specify a user or reply to their message!**" ) user_id, reason = await extract_user_and_reason(message) - user = await app.get_users(user_id) + try: + user = await app.get_users(user_id) + except PeerIdInvalid: + return await message.reply_msg("Sorry, i never meet this user. So i cannot fban.") if not user_id: return await message.reply_text("I can't find that user.") if user_id in all_admins or user_id in SUDO: @@ -871,7 +873,7 @@ async def fbroadcast_message(client, message): sent += 1 await asyncio.sleep(sleep_time) except FloodWait as e: - await asyncio.sleep(int(e.value)) + await asyncio.sleep(e.value) except Exception: pass await m.edit(f"**Broadcasted Message In {sent} Chats.**") diff --git a/misskaty/plugins/genss.py b/misskaty/plugins/genss.py index 777cc6a4..5154bc01 100644 --- a/misskaty/plugins/genss.py +++ b/misskaty/plugins/genss.py @@ -47,8 +47,8 @@ async def genss(self: Client, ctx: Message, strings): url = the_url_parts.strip() file_name = os.path.basename(url) download_file_path = os.path.join("downloads/", file_name) - downloader = SmartDL(url, download_file_path, progress_bar=False, timeout=10, verify=False) try: + downloader = SmartDL(url, download_file_path, progress_bar=False, timeout=10, verify=False) downloader.start(blocking=False) except Exception as err: return await pesan.edit(str(err)) diff --git a/misskaty/plugins/stickers.py b/misskaty/plugins/stickers.py index 3d901464..89ab4e2f 100644 --- a/misskaty/plugins/stickers.py +++ b/misskaty/plugins/stickers.py @@ -168,7 +168,7 @@ async def kang_sticker(self: Client, ctx: Message, strings): elif not reply.sticker.file_name.endswith(".tgs"): resize = True else: - return await prog_msg.edit_msg() + return await prog_msg.edit_msg("I cannot kang this type.") pack_prefix = "anim" if animated else "vid" if videos else "a" packname = f"{pack_prefix}_{ctx.from_user.id}_by_{self.me.username}"