format code
This commit is contained in:
@@ -3,4 +3,3 @@ def format_quote(text:str)->str:
|
||||
if not text.endswith((".", "?", "!")):
|
||||
text += "."
|
||||
return text.upper()
|
||||
|
||||
@@ -11,8 +11,8 @@ def draw_text_in_box(
|
||||
fill="white",
|
||||
spacing=10,
|
||||
):
|
||||
|
||||
# another ai slop function
|
||||
|
||||
draw = ImageDraw.Draw(image)
|
||||
|
||||
x1, y1, x2, y2 = box
|
||||
@@ -42,13 +42,11 @@ def draw_text_in_box(
|
||||
|
||||
return lines
|
||||
|
||||
# Try font sizes from large to small
|
||||
for font_size in range(max_font_size, min_font_size - 1, -1):
|
||||
font = ImageFont.truetype(font_path, font_size)
|
||||
|
||||
lines = wrap_text(text, font)
|
||||
|
||||
# Calculate total text height
|
||||
line_heights = []
|
||||
|
||||
for line in lines:
|
||||
@@ -62,7 +60,6 @@ def draw_text_in_box(
|
||||
else:
|
||||
raise ValueError("Text is too long even at minimum font size")
|
||||
|
||||
# Draw each line centered
|
||||
y = y1 + (box_height - text_height) / 2
|
||||
|
||||
for line, line_height in zip(lines, line_heights):
|
||||
@@ -96,12 +93,11 @@ def generate_quote(text:str):
|
||||
)
|
||||
return img
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("running test")
|
||||
img = Image.open("assets/template.png").convert("RGB")
|
||||
|
||||
|
||||
|
||||
draw_text_in_box(
|
||||
img,
|
||||
"ЬБОПЛВОЛСМЧОЛБМСЧЮ.",
|
||||
|
||||
@@ -15,6 +15,7 @@ bot = None
|
||||
|
||||
works = {}
|
||||
|
||||
|
||||
async def main():
|
||||
global bot
|
||||
cfg = configparser.ConfigParser()
|
||||
@@ -33,10 +34,12 @@ async def main():
|
||||
finally:
|
||||
print("Bot stopped")
|
||||
|
||||
|
||||
@dp.message(F.text, Command("start"))
|
||||
async def start(message: Message):
|
||||
await message.answer(f"usage:\n\n@{(await bot.get_me()).username} some cool quote")
|
||||
|
||||
|
||||
@dp.inline_query()
|
||||
async def inline_query(query: InlineQuery):
|
||||
text = query.query.strip()
|
||||
|
||||
Reference in New Issue
Block a user