diff --git a/misskaty/core/decorator/pyro_cooldown.py b/misskaty/core/decorator/pyro_cooldown.py
index d2bf4e3a..747b274f 100644
--- a/misskaty/core/decorator/pyro_cooldown.py
+++ b/misskaty/core/decorator/pyro_cooldown.py
@@ -1,7 +1,5 @@
from pyrogram import filters
-
-from datetime import datetime
-import datetime as dtime
+from misskaty.core.message_utils import *
import asyncio, time
data = {}
@@ -11,11 +9,11 @@ async def task(msg, warn = False, sec = None):
except:pass
if warn:
user = msg.from_user
- ids = await msg.reply(f"Sorry {user.mention}, you're in cooldown now, wait for {sec}s to use command again..")
+ ids = await kirimPesan(msg, f"Sorry {user.mention} [{user.id}], you must wait for {sec}s before using command again..")
await asyncio.sleep(sec)
- await ids.edit(f"Alright {user.mention}, your cooldown is over you can command again.")
- await asyncio.sleep(1)
- await ids.delete()
+ await editPesan(ids, f"Alright {user.mention} [{user.id}], your cooldown is over you can command again.")
+ await asyncio.sleep(2)
+ await hapusPesan(ids)
def wait(sec):
async def ___(flt, cli, msg):
diff --git a/misskaty/plugins/dev.py b/misskaty/plugins/dev.py
index d17c4afb..af8162ec 100644
--- a/misskaty/plugins/dev.py
+++ b/misskaty/plugins/dev.py
@@ -3,11 +3,12 @@ import io
import os
import sys
import traceback
+from inspect import getfullargspec
from pyrogram import enums, filters
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
-from misskaty import app
+from misskaty import app, user
from misskaty.vars import COMMAND_HANDLER, SUDO
__MODULE__ = "DevCommand"
@@ -21,6 +22,11 @@ __HELP__ = """
/json - Send structure message Telegram in JSON using Pyrogram Style.
"""
+async def edit_or_reply(msg, **kwargs):
+ func = msg.edit_text if msg.from_user.is_self else msg.reply
+ spec = getfullargspec(func.__wrapped__).args
+ await func(**{k: v for k, v in kwargs.items() if k in spec})
+
@app.on_message(filters.command(["logs"], COMMAND_HANDLER) & filters.user(SUDO))
async def log_file(bot, message):
@@ -67,10 +73,12 @@ async def neofetch(c, m):
@app.on_message(filters.command(["shell", "sh"], COMMAND_HANDLER) & filters.user(SUDO))
@app.on_edited_message(filters.command(["shell", "sh"], COMMAND_HANDLER) & filters.user(SUDO))
+@user.on_message(filters.command(["shell", "sh"], ".") & filters.me)
async def shell(_, m):
cmd = m.text.split(" ", 1)
- if len(cmd) == 1:
- return await m.reply("No command to execute was given.")
+ if len(m.command) == 1:
+ return await edit_or_reply(m, text="No command to execute was given.")
+ status_message = await edit_or_reply(m, text="__Processing...__")
shell = (await shell_exec(cmd[1]))[0]
if len(shell) > 3000:
with open("shell_output.txt", "w") as file:
@@ -81,13 +89,14 @@ async def shell(_, m):
file_name=doc.name,
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(text="❌ Close", callback_data=f"close#{m.from_user.id}")]]),
)
+ await status_message.delete()
try:
os.remove("shell_output.txt")
except:
pass
elif len(shell) != 0:
- await m.reply(
- shell,
+ await status_message.edit(
+ text=shell,
parse_mode=enums.ParseMode.HTML,
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(text="❌ Close", callback_data=f"close#{m.from_user.id}")]]),
)
@@ -97,12 +106,12 @@ async def shell(_, m):
@app.on_message(filters.command(["ev", "run"], COMMAND_HANDLER) & filters.user(SUDO))
@app.on_edited_message(filters.command(["ev", "run"]) & filters.user(SUDO))
+@user.on_message(filters.command(["ev", "run"], ".") & filters.me)
async def evaluation_cmd_t(_, m):
- status_message = await m.reply("__Processing eval pyrogram...__")
- try:
- cmd = m.text.split(" ", maxsplit=1)[1]
- except IndexError:
- return await status_message.edit("__No evaluate message!__")
+ cmd = m.text.split(" ", 1)
+ if len(m.command) == 1:
+ return await edit_or_reply(m, text="__No evaluate message!__")
+ status_message = await edit_or_reply(m, text="__Processing eval pyrogram...__")
old_stderr = sys.stderr
old_stdout = sys.stdout
diff --git a/misskaty/plugins/json.py b/misskaty/plugins/json.py
index 4c010973..519d663a 100644
--- a/misskaty/plugins/json.py
+++ b/misskaty/plugins/json.py
@@ -45,15 +45,5 @@ async def jsonify(_, message):
disable_notification=True,
reply_to_message_id=reply_to_id,
thumb="img/thumb.jpg",
- reply_markup=InlineKeyboardMarkup(
- [
- [
- InlineKeyboardButton(
- text="❌ Close",
- callback_data=f"close#{message.from_user.id}",
- )
- ]
- ]
- ),
)
os.remove("json.text")
diff --git a/misskaty/plugins/ytdl_download_new.py b/misskaty/plugins/ytdl_download_new.py
index 04b3fd4b..9204b0e5 100644
--- a/misskaty/plugins/ytdl_download_new.py
+++ b/misskaty/plugins/ytdl_download_new.py
@@ -4,15 +4,13 @@ from uuid import uuid4
from iytdl import iYTDL, main
from pyrogram import filters
-from pyrogram.types import (
- CallbackQuery,
- InlineKeyboardButton,
- InlineKeyboardMarkup,
- InputMediaPhoto,
-)
+from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
+ InlineKeyboardMarkup, InputMediaPhoto)
from misskaty import app
+from misskaty.core.message_utils import *
from misskaty.core.decorator.errors import capture_err
+from misskaty.core.decorator.pyro_cooldown import wait
from misskaty.helper.http import http
from misskaty.vars import COMMAND_HANDLER, LOG_CHANNEL
@@ -25,11 +23,13 @@ def rand_key():
return str(uuid4())[:8]
-@app.on_message(filters.command(["ytsearch"], COMMAND_HANDLER) & ~filters.channel)
+@app.on_message(filters.command(["ytsearch"], COMMAND_HANDLER) & ~filters.channel & wait(30))
@capture_err
async def ytsearch(_, message):
+ if message.sender_chat:
+ return await kirimPesan(message, "This feature not supported for channel.")
if len(message.command) == 1:
- return await message.reply("Please input a query..!")
+ return await kirimPesan(message, "Please input a query..!")
query = message.text.split(" ", maxsplit=1)[1]
search_key = rand_key()
YT_DB[search_key] = query