aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2020-01-22 16:31:58 +0000
committerGravatar jesopo2020-01-22 16:32:21 +0000
commit175e8c0a16daf36bd027168328194df974886d41 (patch)
treebdc3c0f6deb8da1b44eca58ffb658447687f94d8
parentsupport ISUPPORT MODES token having no arg (diff)
signature
change utils.irc.strip_font() to remove tokens, no regex
-rw-r--r--src/utils/irc.py12
1 files changed, 5 insertions, 7 deletions
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,