mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2026-01-09 21:14:52 +00:00
Changed err handler and minor fix in mut button
This commit is contained in:
parent
9fb228c48c
commit
a283daedb8
3 changed files with 17 additions and 31 deletions
|
|
@ -28,7 +28,7 @@ MOD_NOLOAD = ["subscene_dl"]
|
||||||
HELPABLE = {}
|
HELPABLE = {}
|
||||||
cleanmode = {}
|
cleanmode = {}
|
||||||
botStartTime = time.time()
|
botStartTime = time.time()
|
||||||
misskaty_version = "v2.6 - Stable"
|
misskaty_version = "v2.7 - Stable"
|
||||||
|
|
||||||
pymonclient = MongoClient(DATABASE_URI)
|
pymonclient = MongoClient(DATABASE_URI)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import traceback
|
import traceback
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from pyrogram.errors.exceptions.flood_420 import FloodWait
|
from pyrogram.errors.exceptions.flood_420 import FloodWait
|
||||||
from pyrogram.errors.exceptions.forbidden_403 import ChatWriteForbidden
|
from pyrogram.errors.exceptions.forbidden_403 import ChatWriteForbidden
|
||||||
|
|
@ -9,24 +10,6 @@ from misskaty import app
|
||||||
from misskaty.vars import LOG_CHANNEL
|
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):
|
def capture_err(func):
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
async def capture(client, message, *args, **kwargs):
|
async def capture(client, message, *args, **kwargs):
|
||||||
|
|
@ -36,21 +19,24 @@ def capture_err(func):
|
||||||
return await app.leave_chat(message.chat.id)
|
return await app.leave_chat(message.chat.id)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
exc = traceback.format_exc()
|
exc = traceback.format_exc()
|
||||||
error_feedback = split_limits(
|
error_feedback = "ERROR | {} | {}\n\n{}\n\n{}\n".format(
|
||||||
"**ERROR** | `{}` | `{}`\n\n```{}```\n\n```{}```\n".format(
|
|
||||||
message.from_user.id if message.from_user else 0,
|
message.from_user.id if message.from_user else 0,
|
||||||
message.chat.id if message.chat else 0,
|
message.chat.id if message.chat else 0,
|
||||||
message.text or message.caption,
|
message.text or message.caption,
|
||||||
exc,
|
exc,
|
||||||
)
|
)
|
||||||
)
|
day = datetime.today()
|
||||||
|
tgl_now = datetime.now()
|
||||||
|
|
||||||
for x in error_feedback:
|
cap_day = f"{day.strftime('%A')}, {tgl_now.strftime('%d %B %Y %H:%M:%S')}"
|
||||||
try:
|
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...")
|
||||||
await app.send_message(LOG_CHANNEL, x)
|
with open(f"crash_{tgl_now.strftime('%d %B %Y')}.log", "w+", encoding="utf-8") as log:
|
||||||
await message.reply(x)
|
log.write(error_feedback)
|
||||||
except FloodWait as e:
|
log.close()
|
||||||
await asyncio.sleep(e.value)
|
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
|
raise err
|
||||||
|
|
||||||
return capture
|
return capture
|
||||||
|
|
|
||||||
|
|
@ -507,7 +507,7 @@ async def mute(client, message, strings):
|
||||||
return await message.reply_text(strings("mute_admin_err"))
|
return await message.reply_text(strings("mute_admin_err"))
|
||||||
mention = (await app.get_users(user_id)).mention
|
mention = (await app.get_users(user_id)).mention
|
||||||
keyboard = ikb({"🚨 Unmute 🚨": f"unmute_{user_id}"})
|
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":
|
if message.command[0] == "tmute":
|
||||||
split = reason.split(None, 1)
|
split = reason.split(None, 1)
|
||||||
time_value = split[0]
|
time_value = split[0]
|
||||||
|
|
@ -601,7 +601,7 @@ async def remove_warning(_, cq, strings):
|
||||||
strings("no_permission_error").format(permissions=permission),
|
strings("no_permission_error").format(permissions=permission),
|
||||||
show_alert=True,
|
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))
|
warns = await get_warn(chat_id, await int_to_alpha(user_id))
|
||||||
if warns:
|
if warns:
|
||||||
warns = warns["warns"]
|
warns = warns["warns"]
|
||||||
|
|
@ -628,7 +628,7 @@ async def unmute_user(_, cq, strings):
|
||||||
strings("no_permission_error").format(permissions=permission),
|
strings("no_permission_error").format(permissions=permission),
|
||||||
show_alert=True,
|
show_alert=True,
|
||||||
)
|
)
|
||||||
user_id = cq.data.split("_")[1]
|
user_id = int(cq.data.split("_")[1])
|
||||||
text = cq.message.text.markdown
|
text = cq.message.text.markdown
|
||||||
text = f"~~{text}~~\n\n"
|
text = f"~~{text}~~\n\n"
|
||||||
text += strings("rmmute_msg").format(mention=from_user.mention)
|
text += strings("rmmute_msg").format(mention=from_user.mention)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue