This commit is contained in:
Yasir Aris M 2024-07-30 08:26:32 +07:00 committed by GitHub
parent e762872d68
commit 1e9b9716ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -74,8 +74,8 @@ teskode = {}
LOGGER = getLogger("MissKaty")
async def edit_or_reply(msg, **kwargs):
func = msg.edit if msg.from_user.is_self else msg.reply
async def edit_or_reply(self, msg, **kwargs):
func = msg.edit if not self.me.is_bot else msg.reply
spec = getfullargspec(func.__wrapped__).args
await func(**{k: v for k, v in kwargs.items() if k in spec})
@ -339,7 +339,7 @@ async def unban_globally(_, ctx: Message):
@use_chat_lang()
async def shell_cmd(self: Client, ctx: Message, strings):
if len(ctx.command) == 1:
return await edit_or_reply(ctx, text=strings("no_cmd"))
return await edit_or_reply(self, ctx, text=strings("no_cmd"))
msg = (
await ctx.edit_msg(strings("run_exec"))
if not self.me.is_bot
@ -367,6 +367,7 @@ async def shell_cmd(self: Client, ctx: Message, strings):
await msg.delete_msg()
elif len(shell) != 0:
await edit_or_reply(
self,
ctx,
text=html.escape(shell),
parse_mode=enums.ParseMode.HTML,
@ -402,7 +403,7 @@ async def shell_cmd(self: Client, ctx: Message, strings):
@use_chat_lang()
async def cmd_eval(self: Client, ctx: Message, strings) -> Optional[str]:
if (ctx.command and len(ctx.command) == 1) or ctx.text == "app.run()":
return await edit_or_reply(ctx, text=strings("no_eval"))
return await edit_or_reply(self, ctx, text=strings("no_eval"))
status_message = (
await ctx.edit_msg(strings("run_eval"))
if not self.me.is_bot
@ -512,6 +513,7 @@ async def cmd_eval(self: Client, ctx: Message, strings) -> Optional[str]:
await status_message.delete_msg()
else:
await edit_or_reply(
self,
ctx,
text=final_output,
parse_mode=enums.ParseMode.HTML,