change utils.irc.strip_font() to remove tokens, no regex
This commit is contained in:
parent
363fdf01b0
commit
175e8c0a16
1 changed files with 5 additions and 7 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue