Don't ignore a color code when it's right at the end of a message
(src/utils/irc.py)
This commit is contained in:
parent
470f85b009
commit
2331205368
1 changed files with 7 additions and 12 deletions
|
@ -160,27 +160,22 @@ def _format_tokens(s: str) -> typing.List[str]:
|
||||||
is_background = False
|
is_background = False
|
||||||
matches = [] # type: typing.List[str]
|
matches = [] # type: typing.List[str]
|
||||||
|
|
||||||
for char in s:
|
for i, char in enumerate(s):
|
||||||
|
last_char = i == len(s)
|
||||||
if is_color:
|
if is_color:
|
||||||
can_add = False
|
can_add = False
|
||||||
current_color = background if is_background else foreground
|
current_color = background if is_background else foreground
|
||||||
|
color_finished = False
|
||||||
if char.isdigit() and len(current_color) < 2:
|
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:
|
if is_background:
|
||||||
background += char
|
background += char
|
||||||
else:
|
else:
|
||||||
foreground += char
|
foreground += char
|
||||||
continue
|
color_finished = (len(current_color)+1) == 2
|
||||||
elif char == "," and not is_background:
|
|
||||||
|
if char == "," and not is_background:
|
||||||
is_background = True
|
is_background = True
|
||||||
continue
|
elif not char.isdigit() or (color_finished and last_char):
|
||||||
else:
|
|
||||||
color = foreground
|
color = foreground
|
||||||
if background:
|
if background:
|
||||||
color += ","+background
|
color += ","+background
|
||||||
|
|
Loading…
Reference in a new issue