Minor fix

This commit is contained in:
Yasir Aris M 2024-09-13 14:03:53 +07:00 committed by GitHub
parent a5fa7fc5ca
commit 102ec21d7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 28 additions and 18 deletions

View file

@ -46,7 +46,7 @@ MOD_NOLOAD = ["subscene_dl"]
HELPABLE = {}
cleanmode = {}
botStartTime = time.time()
misskaty_version = "v2.15"
misskaty_version = "v2.16.1"
uvloop.install()
faulthandler_enable()

View file

@ -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:

View file

@ -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 @@ async def cmd_eval(self: Client, ctx: Message, strings) -> Optional[str]:
]
]
),
quote=True,
)
await status_message.delete_msg()
else:
@ -596,6 +599,7 @@ async def cmd_eval(self: Client, ctx: Message, strings) -> Optional[str]:
]
]
),
quote=True,
)
if self.me.is_bot:
await status_message.delete_msg()

View file

@ -63,13 +63,13 @@ You can use markdown or html to save text too.
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,
)

View file

@ -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()

View file

@ -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))