From 8bb99a4ee94df6b83a841ae20b6520e745ab98b2 Mon Sep 17 00:00:00 2001 From: Paillat Date: Thu, 3 Aug 2023 13:13:20 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore(opencommit.yml):=20enable?= =?UTF-8?q?=20emoji=20support=20in=20OpenCommit=20workflow=20for=20more=20?= =?UTF-8?q?expressive=20commit=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🗑️ delete(gpt-4.txt): remove unused file containing prompts for Botator, as it is no longer needed --- src/functionscalls.py | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/functionscalls.py b/src/functionscalls.py index 7064fd7..04be1f1 100644 --- a/src/functionscalls.py +++ b/src/functionscalls.py @@ -1,9 +1,10 @@ import discord +import asyncio import aiohttp import random import time from bs4 import BeautifulSoup -from src.config import tenor_api_key +from config import tenor_api_key randomseed = time.time() random.seed(randomseed) @@ -220,11 +221,31 @@ async def send_ascii_art_text( ): font = font_matches[font] text = text.replace(" ", "+") - asciiiar_url = f"https://asciified.thelicato.io/api?text={text}&font={font}" - response = await do_async_request(asciiiar_url, json=False) - message = f"```\n{response}```\n{message}" - await message_in_channel_in_wich_to_send.channel.send(message) - + asciiiar_url = f"https://asciified.thelicato.io/api/v2/ascii?text={text}&font={font}" + print(asciiiar_url) + ascii_art = await do_async_request(asciiiar_url, json=False) + final_message = f"```\n{ascii_art}```\n{message}" + if len(final_message) < 2000: + await message_in_channel_in_wich_to_send.channel.send(final_message) + else: + if len(ascii_art) < 2000: + await message_in_channel_in_wich_to_send.channel.send(ascii_art) + elif len(ascii_art) < 8000: + embed = discord.Embed( + title="Ascii art", + description=ascii_art, + ) + await message_in_channel_in_wich_to_send.channel.send(embed=embed) + else: + await message_in_channel_in_wich_to_send.channel.send( + "Sorry, the ascii art is too big to be sent" + ) + if len (message) < 2000: + await message_in_channel_in_wich_to_send.channel.send(message) + else: + while len(message) > 0: + await message_in_channel_in_wich_to_send.channel.send(message[:2000]) + message = message[2000:] async def send_ascii_art_image( message_in_channel_in_wich_to_send: discord.Message, query: str, message: str = ""