aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar jesopo2019-01-16 12:41:41 +0000
committerGravatar jesopo2019-01-16 12:41:41 +0000
commit2331205368629947b9a516e8b9a0c973899f25e3 (patch)
tree6a6c23b23d07fbf1dedbed235f6ef83a18c1b991 /src
parentPushing logging on to another thread was a ridiculous idea. it means CRITICAL (diff)
signature
Don't ignore a color code when it's right at the end of a message
(src/utils/irc.py)
Diffstat (limited to 'src')
-rw-r--r--src/utils/irc.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/utils/irc.py b/src/utils/irc.py
index b897ee6e..25c170dd 100644
--- a/src/utils/irc.py
+++ b/src/utils/irc.py
@@ -160,27 +160,22 @@ def _format_tokens(s: str) -> typing.List[str]:
is_background = False
matches = [] # type: typing.List[str]
- for char in s:
+ for i, char in enumerate(s):
+ last_char = i == len(s)
if is_color:
can_add = False
current_color = background if is_background else foreground
+ color_finished = False
if char.isdigit() and len(current_color) < 2:
- if current_color:
- next_color = int(current_color + char)
- can_add = next_color <= 99
- else:
- can_add = True
-
- if can_add:
if is_background:
background += char
else:
foreground += char
- continue
- elif char == "," and not is_background:
+ color_finished = (len(current_color)+1) == 2
+
+ if char == "," and not is_background:
is_background = True
- continue
- else:
+ elif not char.isdigit() or (color_finished and last_char):
color = foreground
if background:
color += ","+background