diff --git a/misskaty/__init__.py b/misskaty/__init__.py index 2d390da6bc..8dc0c40bcd 100644 --- a/misskaty/__init__.py +++ b/misskaty/__init__.py @@ -46,7 +46,7 @@ HELPABLE = {} cleanmode = {} botStartTime = time.time() -misskaty_version = "v2.15" +misskaty_version = "v2.16.1" uvloop.install() faulthandler_enable() diff --git a/misskaty/core/misskaty_patch/utils/handler_error.py b/misskaty/core/misskaty_patch/utils/handler_error.py index f01d03a303..7797fb6adc 100644 --- a/misskaty/core/misskaty_patch/utils/handler_error.py +++ b/misskaty/core/misskaty_patch/utils/handler_error.py @@ -52,12 +52,12 @@ async def handle_error( cap_day = f"{day.strftime('%A')}, {tgl_now.strftime('%d %B %Y %H:%M:%S')}" f_errname = f"crash_{tgl_now.strftime('%d %B %Y')}.txt" LOGGER.error(traceback.format_exc()) - with open(f_errname, "w+", encoding="utf-8") as log: - log.write( - f"āœļø Message: {m.text or m.caption}\nšŸ‘±ā€ā™‚ļø User: {m.from_user.id if m.from_user else m.sender_chat.id}\n\n{traceback.format_exc()}" - ) - log.close() if isinstance(m, pyrogram.types.Message): + with open(f_errname, "w+", encoding="utf-8") as log: + log.write( + f"āœļø Message: {m.text or m.caption}\nšŸ‘±ā€ā™‚ļø User: {m.from_user.id if m.from_user else m.sender_chat.id}\n\n{traceback.format_exc()}" + ) + log.close() with contextlib.suppress(Exception): try: await m.reply_photo( @@ -74,6 +74,11 @@ async def handle_error( caption=f"Crash Report of this Bot\n{cap_day}", ) if isinstance(m, pyrogram.types.CallbackQuery): + with open(f_errname, "w+", encoding="utf-8") as log: + log.write( + f"āœļø Message: {m.message.text or m.message.caption}\nšŸ‘±ā€ā™‚ļø User: {m.from_user.id if m.from_user else m.sender_chat.id}\n\n{traceback.format_exc()}" + ) + log.close() with contextlib.suppress(Exception): await m.message.delete() try: diff --git a/misskaty/plugins/dev.py b/misskaty/plugins/dev.py index 88bf9edf8a..93c356f7a9 100644 --- a/misskaty/plugins/dev.py +++ b/misskaty/plugins/dev.py @@ -406,7 +406,7 @@ async def shell_cmd(self: Client, ctx: Message, strings): msg = ( await ctx.edit_msg(strings("run_exec")) if not self.me.is_bot - else await ctx.reply_msg(strings("run_exec")) + else await ctx.reply_msg(strings("run_exec"), quote=True) ) shell = (await shell_exec(ctx.input))[0] if len(shell) > 3000: @@ -426,6 +426,7 @@ async def shell_cmd(self: Client, ctx: Message, strings): ] ] ), + quote=True, ) await msg.delete_msg() elif len(shell) != 0: @@ -444,6 +445,7 @@ async def shell_cmd(self: Client, ctx: Message, strings): ] ] ), + quote=True, ) if self.me.is_bot: await msg.delete_msg() @@ -578,6 +580,7 @@ def _help(*args: Any, **kwargs: Any) -> None: ] ] ), + quote=True, ) await status_message.delete_msg() else: @@ -596,6 +599,7 @@ def _help(*args: Any, **kwargs: Any) -> None: ] ] ), + quote=True, ) if self.me.is_bot: await status_message.delete_msg() diff --git a/misskaty/plugins/filters.py b/misskaty/plugins/filters.py index c376852c34..4e2bea9463 100644 --- a/misskaty/plugins/filters.py +++ b/misskaty/plugins/filters.py @@ -63,13 +63,13 @@ async def save_filters(_, message): try: if len(message.command) < 2 or not message.reply_to_message: - return await message.reply_text( + return await message.reply_msg( "**Usage:**\nReply to a message with /filter [FILTER_NAME] To set a new filter." ) text = message.text.markdown name = text.split(None, 1)[1].strip() if not name: - return await message.reply_text("**Usage:**\n__/filter [FILTER_NAME]__") + return await message.reply_msg("**Usage:**\n__/filter [FILTER_NAME]__") chat_id = message.chat.id replied_message = message.reply_to_message text = name.split(" ", 1) @@ -128,9 +128,9 @@ async def save_filters(_, message): "file_id": file_id, } await save_filter(chat_id, name, _filter) - return await message.reply_text(f"__**Saved filter {name}.**__") + return await message.reply_msg(f"__**Saved filter {name}.**__") except UnboundLocalError: - return await message.reply_text( + return await message.reply_msg( "**Replied message is inaccessible.\n`Forward the message and try again`**" ) @@ -214,7 +214,7 @@ async def filters_re(self, message): message = replied_message if data_type == "text": - await message.reply_text( + await message.reply_msg( text=data, reply_markup=keyb, disable_web_page_preview=True, @@ -274,7 +274,7 @@ async def filters_re(self, message): async def stop_all(_, message): _filters = await get_filters_names(message.chat.id) if not _filters: - await message.reply_text("**No filters in this chat.**") + await message.reply_msg("**No filters in this chat.**") else: keyboard = InlineKeyboardMarkup( [ @@ -284,7 +284,7 @@ async def stop_all(_, message): ] ] ) - await message.reply_text( + await message.reply_msg( "**Are you sure you want to delete all the filters in this chat forever ?.**", reply_markup=keyboard, ) diff --git a/misskaty/plugins/misc_tools.py b/misskaty/plugins/misc_tools.py index 946e4f8c9e..c1d5909f10 100644 --- a/misskaty/plugins/misc_tools.py +++ b/misskaty/plugins/misc_tools.py @@ -568,7 +568,7 @@ async def close_callback(_, query: CallbackQuery): if query.from_user.id != int(userid): with contextlib.suppress(QueryIdInvalid): return await query.answer("āš ļø Access Denied!", True) - with contextlib.redirect_stdout(Exception): + with contextlib.suppress(Exception): await query.answer("Deleting this message in 5 seconds.") await asyncio.sleep(5) await query.message.delete_msg() diff --git a/misskaty/plugins/start_help.py b/misskaty/plugins/start_help.py index 44974ee9be..aca4763c13 100644 --- a/misskaty/plugins/start_help.py +++ b/misskaty/plugins/start_help.py @@ -4,11 +4,11 @@ * @projectName MissKatyPyro * Copyright @YasirPedia All rights reserved """ - +import contextlib import re from pyrogram import Client, filters -from pyrogram.errors import ChatSendPhotosForbidden, ChatWriteForbidden +from pyrogram.errors import ChatSendPhotosForbidden, ChatWriteForbidden, QueryIdInvalid from pyrogram.types import ( CallbackQuery, InlineKeyboardButton, @@ -155,7 +155,8 @@ async def commands_callbacc(_, cb: CallbackQuery): @app.on_callback_query(filters.regex("stats_callback")) async def stats_callbacc(_, cb: CallbackQuery): text = await bot_sys_stats() - await app.answer_callback_query(cb.id, text, show_alert=True) + with contextlib.suppress(QueryIdInvalid): + await app.answer_callback_query(cb.id, text, show_alert=True) @app.on_message(filters.command("help", COMMAND_HANDLER))