Changed base docker to alphine and add again pillow v10 (#179)

* Update chatbot_ai.py

* tes pake alpine

* add again pillow v10

* tes nulis in pil 10

* hmm

* style: format code with black and isort (#180)

Format code with black and isort

This commit fixes the style issues introduced in 41d4f24 according to the output
from Black and isort.

Details: https://app.deepsource.com/gh/yasirarism/MissKatyPyro/transform/ba70f1a7-7e6f-4f79-8251-c9db81fe86c5/

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>

---------

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
This commit is contained in:
yasirarism 2023-07-12 13:44:08 +07:00 committed by GitHub
parent 9cb6a7d77d
commit f6f9b6c007
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 64 additions and 52 deletions

View file

@ -3,17 +3,17 @@
# * @projectName MissKatyPyro # * @projectName MissKatyPyro
# * Copyright ©YasirPedia All rights reserved # * 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 ## With Built in Pip Package
# FROM yasirarism/misskaty-docker:latest FROM yasirarism/misskaty-docker:alpine
## Without Built in Pip Package ## Without Built in Pip Package
FROM yasirarism/misskaty-docker:free # FROM yasirarism/misskaty-docker:free
# Set Hostname # Set Hostname
ENV HOSTNAME misskaty ENV HOSTNAME yasir-server
# Copy Files # Copy Files
COPY . . COPY . .
# Instal pip package # 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 # Set CMD Bot
CMD ["bash", "start.sh"] CMD ["bash", "start.sh"]

View file

@ -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 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.<br/> - Instal requirements.txt, jika menggunakan python 3.11, Anda harus menggunakan opsi venv saat menginstal.<br/>
*Python < 3.10* *Python < 3.10*
``` ```
pip3 install -r requirements.txt pip3 install -r requirements.txt
``` ```
*Python 3.11* *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. - Atur config environment saat menjalankan bot dan jangan lupa isi semua value yang wajib di isi.
- Jalankan Bot - Jalankan Bot

View file

@ -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 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.<br/> - Install requirements.txt, if using python 3.11, you need use venv when install pip package.<br/>
*Python < 3.10* *Python < 3.10*
``` ```
pip3 install -r requirements.txt pip3 install -r requirements.txt
``` ```
*Python 3.11* *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. - Setting your config.env or via environment and dont forget fill all required value.
- Run Bot - Run Bot

BIN
assets/DejaVuSans-Bold.ttf Normal file

Binary file not shown.

BIN
assets/DejaVuSans.ttf Normal file

Binary file not shown.

View file

@ -1,11 +1,15 @@
SUDO=617426792 # Required Vars
API_HASH= API_HASH=
API_ID= API_ID=
BOT_TOKEN= BOT_TOKEN=
DATABASE_NAME=MissKatyDB
DATABASE_URI=mongodb+srv:// DATABASE_URI=mongodb+srv://
LOG_CHANNEL= LOG_CHANNEL=
# Optional Vars
SUDO=617426792
DATABASE_NAME=MissKatyDB
SUPPORT_CHAT=YasirPediaChannel SUPPORT_CHAT=YasirPediaChannel
COMMAND_HANDLER=
USER_SESSION= USER_SESSION=
OPENAI_API= OPENAI_API=
CURRENCY_API= CURRENCY_API=

View file

@ -40,7 +40,7 @@ MOD_NOLOAD = ["subscene_dl"]
HELPABLE = {} HELPABLE = {}
cleanmode = {} cleanmode = {}
botStartTime = time.time() botStartTime = time.time()
misskaty_version = "v2.10.1 - Stable" misskaty_version = "v2.10.2 - Stable"
# Pyrogram Bot Client # Pyrogram Bot Client
app = Client( app = Client(

View file

@ -1,7 +1,6 @@
""" """
* @author yasir <yasiramunandar@gmail.com> * @author yasir <yasiramunandar@gmail.com>
* @date 2022-12-01 09:12:27 * @date 2022-12-01 09:12:27
* @lastModified 2022-12-01 09:33:16
* @projectName MissKatyPyro * @projectName MissKatyPyro
* Copyright @YasirPedia All rights reserved * Copyright @YasirPedia All rights reserved
""" """

View file

@ -14,7 +14,7 @@ def hhmmss(seconds):
async def take_ss(video_file): async def take_ss(video_file):
out_put_file_name = f"genss{str(time.time())}.png" 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) await shell_exec(cmd)
return out_put_file_name if os.path.lexists(out_put_file_name) else None return out_put_file_name if os.path.lexists(out_put_file_name) else None

View file

@ -1,4 +1,4 @@
File name: {{filename}} Filename: {{filename}}
File size: {{size}} File size: {{size}}
Duration: {{duration}} Duration: {{duration}}
Frame Rate: {{frame_rate}} fps Frame Rate: {{frame_rate}} fps

View file

@ -1,7 +1,6 @@
""" """
* @author yasir <yasiramunandar@gmail.com> * @author yasir <yasiramunandar@gmail.com>
* @date 2022-12-01 09:12:27 * @date 2022-12-01 09:12:27
* @lastModified 2022-12-01 09:27:31
* @projectName MissKatyPyro * @projectName MissKatyPyro
* Copyright ©YasirPedia All rights reserved * Copyright ©YasirPedia All rights reserved
""" """

View file

@ -60,7 +60,7 @@ async def openai_chatbot(_, ctx: Message, strings):
answer = "" answer = ""
try: try:
response = await openai.ChatCompletion.acreate( response = await openai.ChatCompletion.acreate(
model="gpt-3.5-turbo", model="gpt-3.5-turbo-0613",
messages=[{"role": "user", "content": pertanyaan}], messages=[{"role": "user", "content": pertanyaan}],
temperature=0.7, temperature=0.7,
stream=True, stream=True,

View file

@ -35,6 +35,7 @@ from pyrogram.types import (
from database.gban_db import add_gban_user, is_gbanned_user, remove_gban_user from database.gban_db import add_gban_user, is_gbanned_user, remove_gban_user
from database.users_chats_db import db from database.users_chats_db import db
from misskaty import BOT_NAME, app, botStartTime, misskaty_version, user 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.eval_helper import format_exception, meval
from misskaty.helper.functions import extract_user, extract_user_and_reason from misskaty.helper.functions import extract_user, extract_user_and_reason
from misskaty.helper.http import http 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)) @app.on_message(filters.command(["stats"], COMMAND_HANDLER))
@new_task
async def server_stats(self: Client, ctx: Message) -> "Message": async def server_stats(self: Client, ctx: Message) -> "Message":
""" """
Give system stats of the server. 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_used = get_readable_file_size(used)
disk_free = get_readable_file_size(free) disk_free = get_readable_file_size(free)
caption = f"<b>{BOT_NAME} {misskaty_version} is Up and Running successfully.</b>\n\n**OS Uptime:** <code>{osuptime}</code>\n<b>Bot Uptime:</b> <code>{currentTime}</code>\n**Bot Usage:** <code>{botusage}</code>\n\n**Total Space:** <code>{disk_total}</code>\n**Free Space:** <code>{disk_free}</code>\n\n**Download:** <code>{download}</code>\n**Upload:** <code>{upload}</code>\n\n<b>Pyrogram Version</b>: <code>{pyrover}</code>\n<b>Python Version</b>: <code>{sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]} {sys.version_info[3].title()}</code>" neofetch = (await shell_exec("neofetch --stdout"))[0]
caption = f"<b>{BOT_NAME} {misskaty_version} is Up and Running successfully.</b>\n\n<code>{neofetch}</code>\n\n**OS Uptime:** <code>{osuptime}</code>\n<b>Bot Uptime:</b> <code>{currentTime}</code>\n**Bot Usage:** <code>{botusage}</code>\n\n**Total Space:** <code>{disk_total}</code>\n**Free Space:** <code>{disk_free}</code>\n\n**Download:** <code>{download}</code>\n**Upload:** <code>{upload}</code>\n\n<b>Pyrogram Version</b>: <code>{pyrover}</code>\n<b>Python Version</b>: <code>{sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]} {sys.version_info[3].title()}</code>"
start = datetime.now() start = datetime.now()
msg = await ctx.reply_photo( 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) @user.on_message(filters.command(["ev", "run", "myeval"], ".") & filters.me)
@use_chat_lang() @use_chat_lang()
@new_task
async def cmd_eval(self: Client, ctx: Message, strings) -> Optional[str]: async def cmd_eval(self: Client, ctx: Message, strings) -> Optional[str]:
if (ctx.command and len(ctx.command) == 1) or ctx.text == "app.run()": if (ctx.command and len(ctx.command) == 1) or ctx.text == "app.run()":
return await edit_or_reply(ctx, text=strings("no_eval")) return await edit_or_reply(ctx, text=strings("no_eval"))

View file

@ -28,7 +28,10 @@ async def draw_meme_text(image_path, text):
current_h, pad = 10, 5 current_h, pad = 10, 5
if upper_text: if upper_text:
for u_text in textwrap.wrap(upper_text, width=15): 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( draw.text(
xy=(((i_width - u_width) / 2) - 1, int((current_h / 640) * i_width)), 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 current_h += u_height + pad
if lower_text: if lower_text:
for l_text in textwrap.wrap(lower_text, width=15): 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( draw.text(
xy=( xy=(

View file

@ -34,7 +34,7 @@ __HELP__ = """"
""" """
@app.on_message(filters.command(["genss"], COMMAND_HANDLER)) @app.on_cmd("genss")
@ratelimiter @ratelimiter
@new_task @new_task
@use_chat_lang() @use_chat_lang()

View file

@ -8,7 +8,7 @@
import os import os
from pyrogram import filters from pyrogram import filters
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
from misskaty import app from misskaty import app
from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.core.decorator.ratelimiter import ratelimiter
@ -16,9 +16,9 @@ from misskaty.vars import COMMAND_HANDLER
# View Structure Telegram Message As JSON # View Structure Telegram Message As JSON
@app.on_message(filters.command(["json"], COMMAND_HANDLER)) @app.on_cmd("json")
@ratelimiter @ratelimiter
async def jsonify(_, message): async def jsonify(_, message: Message):
the_real_message = None the_real_message = None
reply_to_id = None reply_to_id = None
@ -38,13 +38,13 @@ async def jsonify(_, message):
), ),
) )
except Exception as e: 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)) out_file.write(str(the_real_message))
await message.reply_document( await message.reply_document(
document="json.text", document="json.txt",
caption=f"<code>{str(e)}</code>", caption=f"<code>{str(e)}</code>",
disable_notification=True, disable_notification=True,
reply_to_message_id=reply_to_id, reply_to_message_id=reply_to_id,
thumb="assets/thumb.jpg", thumb="assets/thumb.jpg",
) )
os.remove("json.text") os.remove("json.txt")

View file

@ -94,20 +94,16 @@ async def kbbi_search(_, ctx: Client):
@app.on_cmd("carbon") @app.on_cmd("carbon")
async def carbon_make(self: Client, ctx: Message): async def carbon_make(self: Client, ctx: Message):
if len(ctx.command) == 1 and not ctx.reply_to_message: if ctx.reply_to_message and ctx.reply_to_message.text:
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:
text = 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 text = ctx.reply_to_message.caption
else: elif len(ctx.command) > 1:
text = ctx.input text = ctx.input
else:
return await ctx.reply(
"Please reply text to make carbon or add text after command."
)
json_data = { json_data = {
"code": text, "code": text,
"backgroundColor": "#1F816D", "backgroundColor": "#1F816D",

View file

@ -49,7 +49,7 @@ async def handwrite(client, message):
font = ImageFont.truetype("assets/assfont.ttf", 30) font = ImageFont.truetype("assets/assfont.ttf", 30)
x, y = 150, 140 x, y = 150, 140
lines = text_set(txt) lines = text_set(txt)
line_height = font.getsize("hg")[1] line_height = font.getbbox("hg")[3]
for line in lines: for line in lines:
draw.text((x, y), line, fill=(1, 22, 55), font=font) draw.text((x, y), line, fill=(1, 22, 55), font=font)
y = y + line_height - 5 y = y + line_height - 5

View file

@ -254,4 +254,7 @@ async def help_button(self: Client, query: CallbackQuery, strings):
disable_web_page_preview=True, disable_web_page_preview=True,
) )
await self.answer_callback_query(query.id) try:
await self.answer_callback_query(query.id)
except:
pass

View file

@ -5,15 +5,13 @@
import os import os
from asyncio import gather from asyncio import gather
from pyrogram import Client, filters
from pyrogram.types import Message from pyrogram.types import Message
from pySmartDL import SmartDL from pySmartDL import SmartDL
from misskaty import app 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.core.decorator.ratelimiter import ratelimiter
from misskaty.helper.localization import use_chat_lang from misskaty.helper.localization import use_chat_lang
from misskaty.vars import COMMAND_HANDLER
__MODULE__ = "WebSS" __MODULE__ = "WebSS"
__HELP__ = """ __HELP__ = """
@ -21,11 +19,11 @@ __HELP__ = """
""" """
@app.on_message(filters.command(["webss"], COMMAND_HANDLER)) @app.on_cmd("webss")
@capture_err
@ratelimiter @ratelimiter
@new_task
@use_chat_lang() @use_chat_lang()
async def take_ss(self: Client, ctx: Message, strings): async def take_ss(_, ctx: Message, strings):
if len(ctx.command) == 1: if len(ctx.command) == 1:
return await ctx.reply_msg(strings("no_url"), del_in=6) return await ctx.reply_msg(strings("no_url"), del_in=6)
url = ( url = (

View file

@ -158,7 +158,7 @@ async def ytdl_extractinfo_callback(self: Client, cq: CallbackQuery, strings):
@ratelimiter @ratelimiter
@use_chat_lang() @use_chat_lang()
async def ytdl_gendl_callback(self: Client, cq: CallbackQuery, strings): 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 return
match = cq.data.split("|") match = cq.data.split("|")
if cq.from_user.id != cq.message.reply_to_message.from_user.id: if cq.from_user.id != cq.message.reply_to_message.from_user.id:

View file

@ -5,7 +5,7 @@ async_pymongo
pymongo pymongo
python-dotenv python-dotenv
requests requests
bs4 beautifulsoup4
aiohttp aiohttp
chevron chevron
gTTS gTTS
@ -18,7 +18,7 @@ psutil
python-dateutil python-dateutil
telegraph telegraph
hachoir hachoir
Pillow==9.5.0 Pillow==10.0.0
httpx[http2] httpx[http2]
git+https://github.com/yasirarism/vcsi git+https://github.com/yasirarism/vcsi
git+https://github.com/yasirarism/iytdl git+https://github.com/yasirarism/iytdl