diff --git a/misskaty/__init__.py b/misskaty/__init__.py index 53852a03..032fb16f 100644 --- a/misskaty/__init__.py +++ b/misskaty/__init__.py @@ -34,6 +34,7 @@ basicConfig( getLogger("pyrogram").setLevel(ERROR) getLogger("openai").setLevel(ERROR) getLogger("httpx").setLevel(ERROR) +getLogger("iytdl").setLevel(ERROR) MOD_LOAD = [] MOD_NOLOAD = ["subscene_dl"] @@ -55,6 +56,7 @@ app = Client( user = Client( "YasirUBot", session_string=USER_SESSION, + mongodb=dict(connection=AsyncClient(DATABASE_URI), remove_peers=False), ) jobstores = { diff --git a/misskaty/plugins/dev.py b/misskaty/plugins/dev.py index 515d4374..f699f53e 100644 --- a/misskaty/plugins/dev.py +++ b/misskaty/plugins/dev.py @@ -20,6 +20,7 @@ from PIL import Image, ImageDraw, ImageFont from psutil import Process, boot_time, cpu_count, cpu_percent from psutil import disk_usage as disk_usage_percent from psutil import net_io_counters, virtual_memory +from apscheduler.schedulers.asyncio import AsyncIOScheduler from pyrogram import Client from pyrogram import __version__ as pyrover from pyrogram import enums, filters @@ -41,7 +42,7 @@ from misskaty.helper.functions import extract_user, extract_user_and_reason from misskaty.helper.http import http from misskaty.helper.human_read import get_readable_file_size, get_readable_time from misskaty.helper.localization import use_chat_lang -from misskaty.vars import COMMAND_HANDLER, LOG_CHANNEL, SUDO +from misskaty.vars import COMMAND_HANDLER, LOG_CHANNEL, SUDO, AUTO_RESTART __MODULE__ = "DevCommand" __HELP__ = """ @@ -541,3 +542,12 @@ async def shell_exec(code, treat=True): if treat: stdout = stdout.decode().strip() return stdout, process + +async def auto_restart(): + await shell_exec("python3 update.py") + os.execvp(sys.executable, [sys.executable, "-m", "misskaty"]) + +if AUTO_RESTART: + scheduler = AsyncIOScheduler(timezone="Asia/Jakarta") + scheduler.add_job(auto_restart, trigger="interval", days=3) + scheduler.start() \ No newline at end of file diff --git a/misskaty/plugins/quotly.py b/misskaty/plugins/quotly.py index ffd2c0ce..a922f699 100644 --- a/misskaty/plugins/quotly.py +++ b/misskaty/plugins/quotly.py @@ -254,7 +254,7 @@ def isArgInt(txt) -> list: @ratelimiter async def msg_quotly_cmd(self: Client, ctx: Message): is_reply = False - if ctx.command[0][1] == "r": + if ctx.command[0].endswith("r"): is_reply = True if len(ctx.text.split()) > 1: check_arg = isArgInt(ctx.command[1]) @@ -279,7 +279,7 @@ async def msg_quotly_cmd(self: Client, ctx: Message): try: make_quotly = await pyrogram_to_quotly(messages, is_reply=is_reply) bio_sticker = BytesIO(make_quotly) - bio_sticker.name = "biosticker.webp" + bio_sticker.name = "misskatyquote_sticker.webp" return await ctx.reply_sticker(bio_sticker) except Exception: return await ctx.reply_msg("🤷🏻‍♂️") diff --git a/misskaty/vars.py b/misskaty/vars.py index 24d8825b..5c5841c4 100644 --- a/misskaty/vars.py +++ b/misskaty/vars.py @@ -42,6 +42,7 @@ SUDO = list( } ) SUPPORT_CHAT = environ.get("SUPPORT_CHAT", "YasirPediaChannel") +AUTO_RESTART = environ.get("AUTO_RESTART", False) OPENAI_API = getConfig("OPENAI_API") ## Config For AUtoForwarder