From 51b8809f212f21fd9652a7fefe079a026aa4c6cf Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Tue, 29 Jun 2021 17:27:58 -0600 Subject: [PATCH] Smarter body chunking --- jarvis/cogs/jokes.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/jarvis/cogs/jokes.py b/jarvis/cogs/jokes.py index df75fb4..b6a5854 100644 --- a/jarvis/cogs/jokes.py +++ b/jarvis/cogs/jokes.py @@ -69,14 +69,11 @@ class JokeCog(commands.Cog): match, html.unescape(match) ) body_chunks = [] - for i in range(0, len(result["body"]), 1024): - body_chunks.append( - Field( - "​", - result["body"][i * 1024 : (i + 1) * 1024], - False, - ) - ) + + for chunk in result["body"].split("\n"): + if len(chunk) > 0: + body_chunks.append(Field("​", chunk, False)) + fields = body_chunks + [ Field("Score", result["score"]), # Field(