allow requesting utils.irc.color() to not add terminating code
This commit is contained in:
parent
eaf96b6c67
commit
369160d46f
1 changed files with 7 additions and 2 deletions
|
@ -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)
|
REGEX_COLOR = re.compile("%s(?:(\d{1,2})(?:,(\d{1,2}))?)?" % consts.COLOR)
|
||||||
|
|
||||||
def color(s: str, foreground: consts.IRCColor,
|
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)
|
foreground_s = str(foreground.irc).zfill(2)
|
||||||
background_s = ""
|
background_s = ""
|
||||||
if background:
|
if background:
|
||||||
background_s = ",%s" % str(background.irc).zfill(2)
|
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_STOP = ["_", "|", "["]
|
||||||
HASH_COLORS = [consts.CYAN, consts.PURPLE, consts.GREEN, consts.ORANGE,
|
HASH_COLORS = [consts.CYAN, consts.PURPLE, consts.GREEN, consts.ORANGE,
|
||||||
|
|
Loading…
Reference in a new issue