aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar jesopo2020-01-21 16:40:01 +0000
committerGravatar jesopo2020-01-21 16:40:01 +0000
commit369160d46f375f6e578fb1b8d9ede56c75e86e9a (patch)
treed3362edd83fd25e6ba93bd66deece18dcd33ec8b /src/utils
parentadd rainbow.py (diff)
signature
allow requesting utils.irc.color() to not add terminating code
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/irc.py9
1 files 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,