diff --git a/src/utils/irc.py b/src/utils/irc.py index 373f3930..400d5352 100644 --- a/src/utils/irc.py +++ b/src/utils/irc.py @@ -67,13 +67,6 @@ def bold(s: str) -> str: def underline(s: str) -> str: return f"{consts.UNDERLINE}{s}{consts.UNDERLINE}" -def strip_font(s: str) -> str: - s = s.replace(consts.BOLD, "") - s = s.replace(consts.ITALIC, "") - s = REGEX_COLOR.sub("", s) - s = s.replace(consts.COLOR, "") - return s - FORMAT_TOKENS = [ consts.BOLD, consts.RESET, @@ -183,6 +176,11 @@ def parse_format(s: str) -> str: s += consts.ANSI_RESET return s +def strip_font(s: str) -> str: + for token in _format_tokens(s): + s = s.replace(token, "", 1) + return s + OPT_STR = typing.Optional[str] class IRCConnectionParameters(object): def __init__(self, id: int, alias: str, hostname: str, port: int,