diff --git a/Dockerfile b/Dockerfile index 51652036..6ee41d08 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,17 +3,17 @@ # * @projectName MissKatyPyro # * Copyright ©YasirPedia All rights reserved -# Base Docker Using Ubuntu 23.04, Python 3.11 and Built In Pip +# Base Docker Using Alpine 3.18, Python 3.11.4 and Built In Pip ## With Built in Pip Package -# FROM yasirarism/misskaty-docker:latest +FROM yasirarism/misskaty-docker:alpine ## Without Built in Pip Package -FROM yasirarism/misskaty-docker:free +# FROM yasirarism/misskaty-docker:free # Set Hostname -ENV HOSTNAME misskaty +ENV HOSTNAME yasir-server # Copy Files COPY . . # Instal pip package -RUN pip3 install --no-cache-dir -r requirements.txt --break-system-packages +# RUN pip3 install --no-cache-dir -r requirements.txt --break-system-packages # Set CMD Bot CMD ["bash", "start.sh"] diff --git a/README.id.md b/README.id.md index a112f39b..3f802972 100644 --- a/README.id.md +++ b/README.id.md @@ -94,14 +94,15 @@ python3 --version ``` apt update -y & apt install libjpeg-dev zlib1g-dev libwebp-dev python3-pip python3-lxml git wget curl lokal ffmpeg tzdata neofetch mediainfo speedtest-cli -y ``` -- Instal requirements.txt, jika menggunakan python 3.11, Anda harus menambahkan parameter `--break-system-packages` atau gunakan venv saat menginstal.
+- Instal requirements.txt, jika menggunakan python 3.11, Anda harus menggunakan opsi venv saat menginstal.
*Python < 3.10* ``` pip3 install -r requirements.txt ``` *Python 3.11* ``` -pip3 install -r requirements.txt --break-system-packages +Install venv dari terminal server kamu +pip3 install -r requirements.txt ``` - Atur config environment saat menjalankan bot dan jangan lupa isi semua value yang wajib di isi. - Jalankan Bot diff --git a/README.md b/README.md index 09b41547..f0b670ff 100644 --- a/README.md +++ b/README.md @@ -94,14 +94,15 @@ python3 --version ``` apt update -y & apt install libjpeg-dev zlib1g-dev libwebp-dev python3-pip python3-lxml git wget curl ffmpeg locales tzdata neofetch mediainfo speedtest-cli -y ``` -- Install requirements.txt, if using python 3.11, you need pass `--break-system-packages` parameter or use venv when install.
+- Install requirements.txt, if using python 3.11, you need use venv when install pip package.
*Python < 3.10* ``` pip3 install -r requirements.txt ``` *Python 3.11* ``` -pip3 install -r requirements.txt --break-system-packages +Install venv from your terminal and activate it +pip3 install -r requirements.txt ``` - Setting your config.env or via environment and dont forget fill all required value. - Run Bot diff --git a/assets/DejaVuSans-Bold.ttf b/assets/DejaVuSans-Bold.ttf new file mode 100644 index 00000000..0f4d5e9d Binary files /dev/null and b/assets/DejaVuSans-Bold.ttf differ diff --git a/assets/DejaVuSans.ttf b/assets/DejaVuSans.ttf new file mode 100644 index 00000000..e5f7eecc Binary files /dev/null and b/assets/DejaVuSans.ttf differ diff --git a/config.env.sample b/config.env.sample index 97b8333f..3f1ed593 100644 --- a/config.env.sample +++ b/config.env.sample @@ -1,11 +1,15 @@ -SUDO=617426792 +# Required Vars API_HASH= API_ID= BOT_TOKEN= -DATABASE_NAME=MissKatyDB DATABASE_URI=mongodb+srv:// LOG_CHANNEL= + +# Optional Vars +SUDO=617426792 +DATABASE_NAME=MissKatyDB SUPPORT_CHAT=YasirPediaChannel +COMMAND_HANDLER= USER_SESSION= OPENAI_API= -CURRENCY_API= +CURRENCY_API= \ No newline at end of file diff --git a/misskaty/__init__.py b/misskaty/__init__.py index 3bfb6205..93deb365 100644 --- a/misskaty/__init__.py +++ b/misskaty/__init__.py @@ -40,7 +40,7 @@ MOD_NOLOAD = ["subscene_dl"] HELPABLE = {} cleanmode = {} botStartTime = time.time() -misskaty_version = "v2.10.1 - Stable" +misskaty_version = "v2.10.2 - Stable" # Pyrogram Bot Client app = Client( diff --git a/misskaty/__main__.py b/misskaty/__main__.py index d01082a4..f174e681 100644 --- a/misskaty/__main__.py +++ b/misskaty/__main__.py @@ -1,7 +1,6 @@ """ * @author yasir * @date 2022-12-01 09:12:27 - * @lastModified 2022-12-01 09:33:16 * @projectName MissKatyPyro * Copyright @YasirPedia All rights reserved """ diff --git a/misskaty/helper/ffmpeg_helper.py b/misskaty/helper/ffmpeg_helper.py index fa4a748f..f9dfdf7a 100644 --- a/misskaty/helper/ffmpeg_helper.py +++ b/misskaty/helper/ffmpeg_helper.py @@ -14,7 +14,7 @@ def hhmmss(seconds): async def take_ss(video_file): out_put_file_name = f"genss{str(time.time())}.png" - cmd = f"vcsi '{video_file}' -t -w 1340 -g 4x4 --template misskaty/helper/ssgen_template.html --quality 100 --end-delay-percent 20 --metadata-font-size 30 --timestamp-font-size 20 -o {out_put_file_name}" + cmd = f"vcsi '{video_file}' -t -w 1340 -g 4x4 --timestamp-font assets/DejaVuSans.ttf --metadata-font assets/DejaVuSans-Bold.ttf --template misskaty/helper/ssgen_template.html --quality 100 --end-delay-percent 20 --metadata-font-size 30 --timestamp-font-size 20 -o {out_put_file_name}" await shell_exec(cmd) return out_put_file_name if os.path.lexists(out_put_file_name) else None diff --git a/misskaty/helper/ssgen_template.html b/misskaty/helper/ssgen_template.html index 141de300..1517debf 100644 --- a/misskaty/helper/ssgen_template.html +++ b/misskaty/helper/ssgen_template.html @@ -1,4 +1,4 @@ -File name: {{filename}} +Filename: {{filename}} File size: {{size}} Duration: {{duration}} Frame Rate: {{frame_rate}} fps diff --git a/misskaty/plugins/__init__.py b/misskaty/plugins/__init__.py index a7f96b07..086516c4 100644 --- a/misskaty/plugins/__init__.py +++ b/misskaty/plugins/__init__.py @@ -1,7 +1,6 @@ """ * @author yasir * @date 2022-12-01 09:12:27 - * @lastModified 2022-12-01 09:27:31 * @projectName MissKatyPyro * Copyright ©YasirPedia All rights reserved """ diff --git a/misskaty/plugins/chatbot_ai.py b/misskaty/plugins/chatbot_ai.py index 64547e32..317ec543 100644 --- a/misskaty/plugins/chatbot_ai.py +++ b/misskaty/plugins/chatbot_ai.py @@ -60,7 +60,7 @@ async def openai_chatbot(_, ctx: Message, strings): answer = "" try: response = await openai.ChatCompletion.acreate( - model="gpt-3.5-turbo", + model="gpt-3.5-turbo-0613", messages=[{"role": "user", "content": pertanyaan}], temperature=0.7, stream=True, diff --git a/misskaty/plugins/dev.py b/misskaty/plugins/dev.py index dbba9233..7e4c09f0 100644 --- a/misskaty/plugins/dev.py +++ b/misskaty/plugins/dev.py @@ -35,6 +35,7 @@ from pyrogram.types import ( from database.gban_db import add_gban_user, is_gbanned_user, remove_gban_user from database.users_chats_db import db from misskaty import BOT_NAME, app, botStartTime, misskaty_version, user +from misskaty.core.decorator import new_task from misskaty.helper.eval_helper import format_exception, meval from misskaty.helper.functions import extract_user, extract_user_and_reason from misskaty.helper.http import http @@ -119,6 +120,7 @@ async def balas(self: Client, ctx: Message) -> "str": @app.on_message(filters.command(["stats"], COMMAND_HANDLER)) +@new_task async def server_stats(self: Client, ctx: Message) -> "Message": """ Give system stats of the server. @@ -158,7 +160,9 @@ async def server_stats(self: Client, ctx: Message) -> "Message": disk_used = get_readable_file_size(used) disk_free = get_readable_file_size(free) - caption = f"{BOT_NAME} {misskaty_version} is Up and Running successfully.\n\n**OS Uptime:** {osuptime}\nBot Uptime: {currentTime}\n**Bot Usage:** {botusage}\n\n**Total Space:** {disk_total}\n**Free Space:** {disk_free}\n\n**Download:** {download}\n**Upload:** {upload}\n\nPyrogram Version: {pyrover}\nPython Version: {sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]} {sys.version_info[3].title()}" + neofetch = (await shell_exec("neofetch --stdout"))[0] + + caption = f"{BOT_NAME} {misskaty_version} is Up and Running successfully.\n\n{neofetch}\n\n**OS Uptime:** {osuptime}\nBot Uptime: {currentTime}\n**Bot Usage:** {botusage}\n\n**Total Space:** {disk_total}\n**Free Space:** {disk_free}\n\n**Download:** {download}\n**Upload:** {upload}\n\nPyrogram Version: {pyrover}\nPython Version: {sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]} {sys.version_info[3].title()}" start = datetime.now() msg = await ctx.reply_photo( @@ -364,6 +368,7 @@ async def shell(self: Client, ctx: Message, strings) -> "Message": ) @user.on_message(filters.command(["ev", "run", "myeval"], ".") & filters.me) @use_chat_lang() +@new_task 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")) diff --git a/misskaty/plugins/fun.py b/misskaty/plugins/fun.py index 260e3a39..6dcef051 100644 --- a/misskaty/plugins/fun.py +++ b/misskaty/plugins/fun.py @@ -28,7 +28,10 @@ async def draw_meme_text(image_path, text): current_h, pad = 10, 5 if upper_text: for u_text in textwrap.wrap(upper_text, width=15): - u_width, u_height = draw.textsize(u_text, font=m_font) + text_bbox = m_font.getbbox(u_text) + (left, top, right, bottom) = text_bbox + u_width = abs(right - left) + u_height = abs(top - bottom) draw.text( xy=(((i_width - u_width) / 2) - 1, int((current_h / 640) * i_width)), @@ -72,7 +75,10 @@ async def draw_meme_text(image_path, text): current_h += u_height + pad if lower_text: for l_text in textwrap.wrap(lower_text, width=15): - u_width, u_height = draw.textsize(l_text, font=m_font) + text_bbox = m_font.getbbox(u_text) + (left, top, right, bottom) = text_bbox + u_width = abs(right - left) + u_height = abs(top - bottom) draw.text( xy=( @@ -177,4 +183,4 @@ async def memify(client, message): @use_chat_lang() async def dice(c, m, strings): dices = await c.send_dice(m.chat.id, reply_to_message_id=m.id) - await dices.reply_msg(strings("result").format(number=dices.dice.value), quote=True) \ No newline at end of file + await dices.reply_msg(strings("result").format(number=dices.dice.value), quote=True) diff --git a/misskaty/plugins/genss.py b/misskaty/plugins/genss.py index 7167b364..5c7a13ea 100644 --- a/misskaty/plugins/genss.py +++ b/misskaty/plugins/genss.py @@ -34,7 +34,7 @@ __HELP__ = """" """ -@app.on_message(filters.command(["genss"], COMMAND_HANDLER)) +@app.on_cmd("genss") @ratelimiter @new_task @use_chat_lang() diff --git a/misskaty/plugins/json.py b/misskaty/plugins/json.py index 7a7925c0..0e65dcfa 100644 --- a/misskaty/plugins/json.py +++ b/misskaty/plugins/json.py @@ -8,7 +8,7 @@ import os from pyrogram import filters -from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup +from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message from misskaty import app from misskaty.core.decorator.ratelimiter import ratelimiter @@ -16,9 +16,9 @@ from misskaty.vars import COMMAND_HANDLER # View Structure Telegram Message As JSON -@app.on_message(filters.command(["json"], COMMAND_HANDLER)) +@app.on_cmd("json") @ratelimiter -async def jsonify(_, message): +async def jsonify(_, message: Message): the_real_message = None reply_to_id = None @@ -38,13 +38,13 @@ async def jsonify(_, message): ), ) except Exception as e: - with open("json.text", "w+", encoding="utf8") as out_file: + with open("json.txt", "w+", encoding="utf8") as out_file: out_file.write(str(the_real_message)) await message.reply_document( - document="json.text", + document="json.txt", caption=f"{str(e)}", disable_notification=True, reply_to_message_id=reply_to_id, thumb="assets/thumb.jpg", ) - os.remove("json.text") + os.remove("json.txt") diff --git a/misskaty/plugins/misc_tools.py b/misskaty/plugins/misc_tools.py index d0d5f440..6b7de18d 100644 --- a/misskaty/plugins/misc_tools.py +++ b/misskaty/plugins/misc_tools.py @@ -94,20 +94,16 @@ async def kbbi_search(_, ctx: Client): @app.on_cmd("carbon") async def carbon_make(self: Client, ctx: Message): - if len(ctx.command) == 1 and not ctx.reply_to_message: - return await ctx.reply( - "Please reply text to make carbon or add text after command." - ) - if not ctx.reply_to_message: - return await ctx.reply( - "Please reply text to make carbon or add text after command." - ) - if ctx.reply_to_message.text: + if ctx.reply_to_message and ctx.reply_to_message.text: text = ctx.reply_to_message.text - elif ctx.reply_to_message.caption: + elif ctx.reply_to_message and ctx.reply_to_message.caption: text = ctx.reply_to_message.caption - else: + elif len(ctx.command) > 1: text = ctx.input + else: + return await ctx.reply( + "Please reply text to make carbon or add text after command." + ) json_data = { "code": text, "backgroundColor": "#1F816D", diff --git a/misskaty/plugins/nulis.py b/misskaty/plugins/nulis.py index eb7faf38..d605e218 100644 --- a/misskaty/plugins/nulis.py +++ b/misskaty/plugins/nulis.py @@ -49,7 +49,7 @@ async def handwrite(client, message): font = ImageFont.truetype("assets/assfont.ttf", 30) x, y = 150, 140 lines = text_set(txt) - line_height = font.getsize("hg")[1] + line_height = font.getbbox("hg")[3] for line in lines: draw.text((x, y), line, fill=(1, 22, 55), font=font) y = y + line_height - 5 diff --git a/misskaty/plugins/start_help.py b/misskaty/plugins/start_help.py index 9245a949..a02148dc 100644 --- a/misskaty/plugins/start_help.py +++ b/misskaty/plugins/start_help.py @@ -254,4 +254,7 @@ async def help_button(self: Client, query: CallbackQuery, strings): disable_web_page_preview=True, ) - await self.answer_callback_query(query.id) + try: + await self.answer_callback_query(query.id) + except: + pass diff --git a/misskaty/plugins/webss.py b/misskaty/plugins/webss.py index 3fd9e824..4a2ffec3 100644 --- a/misskaty/plugins/webss.py +++ b/misskaty/plugins/webss.py @@ -5,15 +5,13 @@ import os from asyncio import gather -from pyrogram import Client, filters from pyrogram.types import Message 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.localization import use_chat_lang -from misskaty.vars import COMMAND_HANDLER __MODULE__ = "WebSS" __HELP__ = """ @@ -21,11 +19,11 @@ __HELP__ = """ """ -@app.on_message(filters.command(["webss"], COMMAND_HANDLER)) -@capture_err +@app.on_cmd("webss") @ratelimiter +@new_task @use_chat_lang() -async def take_ss(self: Client, ctx: Message, strings): +async def take_ss(_, ctx: Message, strings): if len(ctx.command) == 1: return await ctx.reply_msg(strings("no_url"), del_in=6) url = ( diff --git a/misskaty/plugins/ytdl_plugins.py b/misskaty/plugins/ytdl_plugins.py index 3534ed90..49056870 100644 --- a/misskaty/plugins/ytdl_plugins.py +++ b/misskaty/plugins/ytdl_plugins.py @@ -158,7 +158,7 @@ async def ytdl_extractinfo_callback(self: Client, cq: CallbackQuery, strings): @ratelimiter @use_chat_lang() async def ytdl_gendl_callback(self: Client, cq: CallbackQuery, strings): - if not cq.message.reply_to_message.from_user: + if not (cq.message.reply_to_message and cq.message.reply_to_message.from_user): return match = cq.data.split("|") if cq.from_user.id != cq.message.reply_to_message.from_user.id: diff --git a/requirements.txt b/requirements.txt index 60ea25b7..616fca7c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ async_pymongo pymongo python-dotenv requests -bs4 +beautifulsoup4 aiohttp chevron gTTS @@ -18,7 +18,7 @@ psutil python-dateutil telegraph hachoir -Pillow==9.5.0 +Pillow==10.0.0 httpx[http2] git+https://github.com/yasirarism/vcsi git+https://github.com/yasirarism/iytdl @@ -28,4 +28,4 @@ pyrate_limiter cachetools cloudscraper openai -GitPython +GitPython \ No newline at end of file