1
0
Fork 0

Add utils.py

This commit is contained in:
Eric Lay 2025-05-04 20:04:34 -05:00
parent 9c0b2d8744
commit 28c45d1884
1 changed files with 12 additions and 0 deletions

12
utils.py Normal file
View File

@ -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"