This commit is contained in:
yasir 2023-02-01 22:04:19 +07:00
parent ac32abb63d
commit 365028be77
4 changed files with 32 additions and 35 deletions

View file

@ -1,7 +1,5 @@
from pyrogram import filters from pyrogram import filters
from misskaty.core.message_utils import *
from datetime import datetime
import datetime as dtime
import asyncio, time import asyncio, time
data = {} data = {}
@ -11,11 +9,11 @@ async def task(msg, warn = False, sec = None):
except:pass except:pass
if warn: if warn:
user = msg.from_user 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} [<code>{user.id}</code>], you must wait for {sec}s before using command again..")
await asyncio.sleep(sec) await asyncio.sleep(sec)
await ids.edit(f"Alright {user.mention}, your cooldown is over you can command again.") await editPesan(ids, f"Alright {user.mention} [<code>{user.id}</code>], your cooldown is over you can command again.")
await asyncio.sleep(1) await asyncio.sleep(2)
await ids.delete() await hapusPesan(ids)
def wait(sec): def wait(sec):
async def ___(flt, cli, msg): async def ___(flt, cli, msg):

View file

@ -3,11 +3,12 @@ import io
import os import os
import sys import sys
import traceback import traceback
from inspect import getfullargspec
from pyrogram import enums, filters from pyrogram import enums, filters
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from misskaty import app from misskaty import app, user
from misskaty.vars import COMMAND_HANDLER, SUDO from misskaty.vars import COMMAND_HANDLER, SUDO
__MODULE__ = "DevCommand" __MODULE__ = "DevCommand"
@ -21,6 +22,11 @@ __HELP__ = """
/json - Send structure message Telegram in JSON using Pyrogram Style. /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)) @app.on_message(filters.command(["logs"], COMMAND_HANDLER) & filters.user(SUDO))
async def log_file(bot, message): 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_message(filters.command(["shell", "sh"], COMMAND_HANDLER) & filters.user(SUDO))
@app.on_edited_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): async def shell(_, m):
cmd = m.text.split(" ", 1) cmd = m.text.split(" ", 1)
if len(cmd) == 1: if len(m.command) == 1:
return await m.reply("No command to execute was given.") 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] shell = (await shell_exec(cmd[1]))[0]
if len(shell) > 3000: if len(shell) > 3000:
with open("shell_output.txt", "w") as file: with open("shell_output.txt", "w") as file:
@ -81,13 +89,14 @@ async def shell(_, m):
file_name=doc.name, file_name=doc.name,
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(text="❌ Close", callback_data=f"close#{m.from_user.id}")]]), reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(text="❌ Close", callback_data=f"close#{m.from_user.id}")]]),
) )
await status_message.delete()
try: try:
os.remove("shell_output.txt") os.remove("shell_output.txt")
except: except:
pass pass
elif len(shell) != 0: elif len(shell) != 0:
await m.reply( await status_message.edit(
shell, text=shell,
parse_mode=enums.ParseMode.HTML, parse_mode=enums.ParseMode.HTML,
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(text="❌ Close", callback_data=f"close#{m.from_user.id}")]]), 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_message(filters.command(["ev", "run"], COMMAND_HANDLER) & filters.user(SUDO))
@app.on_edited_message(filters.command(["ev", "run"]) & 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): async def evaluation_cmd_t(_, m):
status_message = await m.reply("__Processing eval pyrogram...__") cmd = m.text.split(" ", 1)
try: if len(m.command) == 1:
cmd = m.text.split(" ", maxsplit=1)[1] return await edit_or_reply(m, text="__No evaluate message!__")
except IndexError: status_message = await edit_or_reply(m, text="__Processing eval pyrogram...__")
return await status_message.edit("__No evaluate message!__")
old_stderr = sys.stderr old_stderr = sys.stderr
old_stdout = sys.stdout old_stdout = sys.stdout

View file

@ -45,15 +45,5 @@ async def jsonify(_, message):
disable_notification=True, disable_notification=True,
reply_to_message_id=reply_to_id, reply_to_message_id=reply_to_id,
thumb="img/thumb.jpg", thumb="img/thumb.jpg",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{message.from_user.id}",
)
]
]
),
) )
os.remove("json.text") os.remove("json.text")

View file

@ -4,15 +4,13 @@ from uuid import uuid4
from iytdl import iYTDL, main from iytdl import iYTDL, main
from pyrogram import filters from pyrogram import filters
from pyrogram.types import ( from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
CallbackQuery, InlineKeyboardMarkup, InputMediaPhoto)
InlineKeyboardButton,
InlineKeyboardMarkup,
InputMediaPhoto,
)
from misskaty import app from misskaty import app
from misskaty.core.message_utils import *
from misskaty.core.decorator.errors import capture_err from misskaty.core.decorator.errors import capture_err
from misskaty.core.decorator.pyro_cooldown import wait
from misskaty.helper.http import http from misskaty.helper.http import http
from misskaty.vars import COMMAND_HANDLER, LOG_CHANNEL from misskaty.vars import COMMAND_HANDLER, LOG_CHANNEL
@ -25,11 +23,13 @@ def rand_key():
return str(uuid4())[:8] 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 @capture_err
async def ytsearch(_, message): async def ytsearch(_, message):
if message.sender_chat:
return await kirimPesan(message, "This feature not supported for channel.")
if len(message.command) == 1: 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] query = message.text.split(" ", maxsplit=1)[1]
search_key = rand_key() search_key = rand_key()
YT_DB[search_key] = query YT_DB[search_key] = query