diff --git a/misskaty/__init__.py b/misskaty/__init__.py index 386bfb01..a7c7cdee 100644 --- a/misskaty/__init__.py +++ b/misskaty/__init__.py @@ -28,7 +28,7 @@ MOD_NOLOAD = ["subscene_dl"] HELPABLE = {} cleanmode = {} botStartTime = time.time() -misskaty_version = "v2.6 - Stable" +misskaty_version = "v2.7 - Stable" pymonclient = MongoClient(DATABASE_URI) diff --git a/misskaty/core/decorator/errors.py b/misskaty/core/decorator/errors.py index 26d92d19..64ef6516 100644 --- a/misskaty/core/decorator/errors.py +++ b/misskaty/core/decorator/errors.py @@ -1,6 +1,7 @@ import asyncio import traceback from functools import wraps +from datetime import datetime from pyrogram.errors.exceptions.flood_420 import FloodWait from pyrogram.errors.exceptions.forbidden_403 import ChatWriteForbidden @@ -9,24 +10,6 @@ from misskaty import app from misskaty.vars import LOG_CHANNEL -def split_limits(text): - if len(text) < 2048: - return [text] - - lines = text.splitlines(True) - small_msg = "" - result = [] - for line in lines: - if len(small_msg) + len(line) < 2048: - small_msg += line - else: - result.append(small_msg) - small_msg = line - result.append(small_msg) - - return result - - def capture_err(func): @wraps(func) async def capture(client, message, *args, **kwargs): @@ -36,21 +19,24 @@ def capture_err(func): return await app.leave_chat(message.chat.id) except Exception as err: exc = traceback.format_exc() - error_feedback = split_limits( - "**ERROR** | `{}` | `{}`\n\n```{}```\n\n```{}```\n".format( + error_feedback = "ERROR | {} | {}\n\n{}\n\n{}\n".format( message.from_user.id if message.from_user else 0, message.chat.id if message.chat else 0, message.text or message.caption, exc, - ) ) + day = datetime.today() + tgl_now = datetime.now() - for x in error_feedback: - try: - await app.send_message(LOG_CHANNEL, x) - await message.reply(x) - except FloodWait as e: - await asyncio.sleep(e.value) + cap_day = f"{day.strftime('%A')}, {tgl_now.strftime('%d %B %Y %H:%M:%S')}" + await message.reply("😭 An Internal Error Occurred while processing your Command, the Logs have been sent to the Owners of this Bot. Sorry for Inconvenience...") + with open(f"crash_{tgl_now.strftime('%d %B %Y')}.log", "w+", encoding="utf-8") as log: + log.write(error_feedback) + log.close() + await app.send_document( + LOG_CHANNEL, f"crash_{tgl_now.strftime('%d %B %Y')}.log", caption=f"Crash Report of this Bot\n{cap_day}" + ) + os.remove(f"crash_{tgl_now.strftime('%d %B %Y')}.log") raise err return capture diff --git a/misskaty/plugins/admin.py b/misskaty/plugins/admin.py index 23f438a9..bd6d3031 100644 --- a/misskaty/plugins/admin.py +++ b/misskaty/plugins/admin.py @@ -507,7 +507,7 @@ async def mute(client, message, strings): return await message.reply_text(strings("mute_admin_err")) mention = (await app.get_users(user_id)).mention keyboard = ikb({"🚨 Unmute 🚨": f"unmute_{user_id}"}) - msg = strings("muted_msg").format(mention=mention, muter=message.from_user.mention if message.from_user else "Anon") + msg = strings("mute_msg").format(mention=mention, muter=message.from_user.mention if message.from_user else "Anon") if message.command[0] == "tmute": split = reason.split(None, 1) time_value = split[0] @@ -601,7 +601,7 @@ async def remove_warning(_, cq, strings): strings("no_permission_error").format(permissions=permission), show_alert=True, ) - user_id = cq.data.split("_")[1] + user_id = int(cq.data.split("_")[1]) warns = await get_warn(chat_id, await int_to_alpha(user_id)) if warns: warns = warns["warns"] @@ -628,7 +628,7 @@ async def unmute_user(_, cq, strings): strings("no_permission_error").format(permissions=permission), show_alert=True, ) - user_id = cq.data.split("_")[1] + user_id = int(cq.data.split("_")[1]) text = cq.message.text.markdown text = f"~~{text}~~\n\n" text += strings("rmmute_msg").format(mention=from_user.mention)