Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yasirarism authored Sep 13, 2024
1 parent a5fa7fc commit 102ec21
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 18 deletions.
2 changes: 1 addition & 1 deletion misskaty/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
HELPABLE = {}
cleanmode = {}
botStartTime = time.time()
misskaty_version = "v2.15"
misskaty_version = "v2.16.1"

uvloop.install()
faulthandler_enable()
Expand Down
15 changes: 10 additions & 5 deletions misskaty/core/misskaty_patch/utils/handler_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion misskaty/plugins/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -426,6 +426,7 @@ async def shell_cmd(self: Client, ctx: Message, strings):
]
]
),
quote=True,
)
await msg.delete_msg()
elif len(shell) != 0:
Expand All @@ -444,6 +445,7 @@ async def shell_cmd(self: Client, ctx: Message, strings):
]
]
),
quote=True,
)
if self.me.is_bot:
await msg.delete_msg()
Expand Down Expand Up @@ -578,6 +580,7 @@ def _help(*args: Any, **kwargs: Any) -> None:
]
]
),
quote=True,
)
await status_message.delete_msg()
else:
Expand All @@ -596,6 +599,7 @@ def _help(*args: Any, **kwargs: Any) -> None:
]
]
),
quote=True,
)
if self.me.is_bot:
await status_message.delete_msg()
Expand Down
14 changes: 7 additions & 7 deletions misskaty/plugins/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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`**"
)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
[
Expand All @@ -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,
)
Expand Down
2 changes: 1 addition & 1 deletion misskaty/plugins/misc_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 4 additions & 3 deletions misskaty/plugins/start_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 102ec21

Please sign in to comment.