From 3a755bb15fd115f82678ed3e66ecda7ca1a0fe2e Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 25 Oct 2019 17:12:24 +0100 Subject: [PATCH] don't consume past 2nd digit in e.g. "\03033,123" --- src/utils/irc/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/irc/__init__.py b/src/utils/irc/__init__.py index bd7c09ec..160d55c2 100644 --- a/src/utils/irc/__init__.py +++ b/src/utils/irc/__init__.py @@ -122,19 +122,19 @@ def _format_tokens(s: str) -> typing.List[str]: for i, char in enumerate(s): last_char = i == len(s)-1 if is_color: - can_add = False current_color = background if is_background else foreground - color_finished = False + color_finished = True if char.isdigit() and len(current_color) < 2: if is_background: background += char else: foreground += char color_finished = (len(current_color)+1) == 2 - - if char == "," and not is_background: + elif char == "," and not is_background: is_background = True - elif not char.isdigit() or (color_finished and last_char): + color_finished = False + + if not char.isdigit() or last_char or color_finished: color = foreground if background: color += ","+background