From 369160d46f375f6e578fb1b8d9ede56c75e86e9a Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 21 Jan 2020 16:40:01 +0000 Subject: [PATCH] allow requesting utils.irc.color() to not add terminating code --- src/utils/irc.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/utils/irc.py b/src/utils/irc.py index 153d6405..adc62a32 100644 --- a/src/utils/irc.py +++ b/src/utils/irc.py @@ -32,13 +32,18 @@ def equals(case_mapping: str, s1: str, s2: str) -> bool: REGEX_COLOR = re.compile("%s(?:(\d{1,2})(?:,(\d{1,2}))?)?" % consts.COLOR) def color(s: str, foreground: consts.IRCColor, - background: consts.IRCColor=None) -> str: + background: consts.IRCColor=None, + terminate: bool=True) -> str: foreground_s = str(foreground.irc).zfill(2) background_s = "" if background: background_s = ",%s" % str(background.irc).zfill(2) - return f"{consts.COLOR}{foreground_s}{background_s}{s}{consts.COLOR}" + out = f"{consts.COLOR}{foreground_s}{background_s}{s}" + if terminate: + out += consts.COLOR + + return out HASH_STOP = ["_", "|", "["] HASH_COLORS = [consts.CYAN, consts.PURPLE, consts.GREEN, consts.ORANGE,