From 28c45d1884525e9dc8f56261975c10ea123168d2 Mon Sep 17 00:00:00 2001 From: Eric Lay Date: Sun, 4 May 2025 20:04:34 -0500 Subject: [PATCH] Add utils.py --- utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 utils.py diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..583f968 --- /dev/null +++ b/utils.py @@ -0,0 +1,12 @@ +import re + +# Strip bbcode coming into ircBridge from site chatbox +def strip_bbcode(text): + # Matches BBCode tags like [tag], [tag=value], [/tag] + return re.sub(r'\[(\/?)?(color|size|pre|img|url|b|i|u|style)(=[^\]]+)?\]', '', text, flags=re.IGNORECASE) + +# Extract username from an IRC line +def parse_username(line): + if line.startswith(":"): + return line[1:].split("!")[0] + return "UnknownUser"