From 6b59830a6ea4e22796bff658d5c10a58d4695b2b Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 6 Mar 2019 21:48:31 +0000 Subject: [PATCH] Only print ANSI reset characters when appropriate --- src/utils/irc/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/utils/irc/__init__.py b/src/utils/irc/__init__.py index 381e3116..d2897deb 100644 --- a/src/utils/irc/__init__.py +++ b/src/utils/irc/__init__.py @@ -212,7 +212,16 @@ def parse_format(s: str) -> str: s = s.replace(token, replace, 1) - return s + utils.consts.ANSI_RESET + if has_foreground: + s += utils.consts.ANSI_FOREGROUND_RESET + if has_background: + s += utils.consts.ANSI_BACKGROUND_RESET + if bold: + s += utils.consts.ANSI_BOLD_RESET + if underline: + s += utils.consts.ANSI_UNDERLINE_RESET + + return s OPT_STR = typing.Optional[str] class IRCConnectionParameters(object):