diff --git a/PIcontroller.py b/PIcontroller.py index 05f5364..33e3807 100644 --- a/PIcontroller.py +++ b/PIcontroller.py @@ -20,11 +20,19 @@ def listfromAPI(message): def fixformatting(message): try: + fixedmessage = [""] counter = 0 for word in message.split(" "): - pass + if counter + len(word) >= 22: + counter = 0 + fixedmessage.append("\n") + fixedmessage.append("{} ".format(word)) + else: + counter += len(word) + fixedmessage.append("{} ".format(word)) + return "".join(fixedmessage) except: - return message + return "".join(fixedmessage) def main(): @@ -32,7 +40,7 @@ def main(): response = listfromAPI(response) if response == None: return if len(response) == 1: - sendUpdate(response[0]) + sendUpdate(fixformatting(response[0])) requests.get("{}/clear?api={}".format(LoveBOXAPIurl,LoveBOXAPIapi), verify=True).content.decode()