mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 17:44:50 +00:00
Tes thread
This commit is contained in:
parent
1679648c4e
commit
308467ed1c
6 changed files with 26 additions and 16 deletions
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"githubPullRequests.ignoredPullRequestBranches": [
|
||||
"master"
|
||||
]
|
||||
}
|
||||
3
misskaty/core/decorator/__init__.py
Normal file
3
misskaty/core/decorator/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from .errors import *
|
||||
from .misc import *
|
||||
from .permissions import *
|
||||
|
|
@ -9,15 +9,6 @@ from misskaty import app
|
|||
from misskaty.vars import LOG_CHANNEL
|
||||
|
||||
|
||||
def asyncify(func):
|
||||
async def inner(*args, **kwargs):
|
||||
loop = asyncio.get_running_loop()
|
||||
func_out = await loop.run_in_executor(None, func, *args, **kwargs)
|
||||
return func_out
|
||||
|
||||
return inner
|
||||
|
||||
|
||||
def split_limits(text):
|
||||
if len(text) < 2048:
|
||||
return [text]
|
||||
|
|
|
|||
20
misskaty/core/decorator/misc.py
Normal file
20
misskaty/core/decorator/misc.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import asyncio
|
||||
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
def asyncify(func):
|
||||
async def inner(*args, **kwargs):
|
||||
func_out = await loop.run_in_executor(None, func, *args, **kwargs)
|
||||
return func_out
|
||||
|
||||
return inner
|
||||
|
||||
def new_task(func):
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
try:
|
||||
return loop.create_task(func(*args, **kwargs))
|
||||
except Exception as e:
|
||||
LOGGER.error(f"Failed to create task for {func.__name__} : {e}")
|
||||
|
||||
return wrapper
|
||||
|
|
@ -11,7 +11,7 @@ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
|
|||
from pySmartDL import SmartDL
|
||||
|
||||
from misskaty import app
|
||||
from misskaty.core.decorator.errors import capture_err
|
||||
from misskaty.core.decorator import capture_err, new_task
|
||||
from misskaty.core.decorator.ratelimiter import ratelimiter
|
||||
from misskaty.helper.http import http
|
||||
from misskaty.helper.pyro_progress import humanbytes, progress_for_pyrogram
|
||||
|
|
@ -63,6 +63,7 @@ async def upload(bot, message):
|
|||
|
||||
@app.on_message(filters.command(["download"], COMMAND_HANDLER) & filters.user(SUDO))
|
||||
@capture_err
|
||||
@new_task
|
||||
async def download(client, message):
|
||||
pesan = await message.reply_text("Processing...", quote=True)
|
||||
if message.reply_to_message is not None:
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from pyrogram.types import ChatMemberUpdated, InlineKeyboardButton, InlineKeyboa
|
|||
from database.users_chats_db import db
|
||||
from misskaty import BOT_USERNAME, app
|
||||
from misskaty.core.decorator.ratelimiter import ratelimiter
|
||||
from misskaty.core.decorator.errors import asyncify, capture_err
|
||||
from misskaty.core.decorator import asyncify, capture_err
|
||||
from misskaty.helper.http import http
|
||||
from misskaty.helper.localization import use_chat_lang
|
||||
from misskaty.vars import COMMAND_HANDLER, LOG_CHANNEL, SUDO, SUPPORT_CHAT
|
||||
|
|
|
|||
Loading…
Reference in a new issue