From 143e1a211b9670b66fe0d021dc1144fd192be07c Mon Sep 17 00:00:00 2001 From: Sven Knebel Date: Sat, 4 Jan 2020 15:31:14 +0100 Subject: [PATCH] bugfix: skip newline after automatically inserted newlines Fixes https://github.com/Chaostreff-Potsdam/erika3004/issues/32 --- erika/tcp_server.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/erika/tcp_server.py b/erika/tcp_server.py index 73539e4..e086304 100755 --- a/erika/tcp_server.py +++ b/erika/tcp_server.py @@ -26,16 +26,24 @@ def print_to_erika(sanitized_tweet): erika.crlf() xpos = 0 - for i in range(0, len(sanitized_tweet)): - erika.print_ascii(sanitized_tweet[i]) + just_overflow = False + for c in sanitized_tweet: xpos += 1 - if sanitized_tweet[i] == '\n': + if c == '\n': xpos = 0 + if just_overflow: + just_overflow = False + continue + + just_overflow = False + erika.print_ascii(c) if xpos >= ERIKA_MAX_LINE_LENGTH: erika.crlf() xpos = 0 + just_overflow = True + while True: