From 895e107f00c9c2cb0e805d85936e342fc210adfa Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Tue, 24 Nov 2020 00:50:30 -0500 Subject: [PATCH] [+] Create wrap function --- src/utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils.py b/src/utils.py index 53de374..732ecba 100644 --- a/src/utils.py +++ b/src/utils.py @@ -1,4 +1,5 @@ import json +import textwrap from urllib.parse import unquote import requests @@ -91,3 +92,7 @@ def render(message): formatter = ImageFormatter(font_name="sarasa-mono-cl-regular", style="colorful", font_size=12, line_pad=4) result = syntax_highlight(message, lexer, formatter, outfile=None) return result + + +def wrap(string: str): + return '\n'.join([' ⏎\n '.join(textwrap.wrap(line, 120)) for line in string.splitlines()])