Add utils.py
This commit is contained in:
parent
9c0b2d8744
commit
28c45d1884
|
@ -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"
|
Loading…
Reference in New Issue