Parse channel tags to make them easier to read

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2016-11-16 10:34:37 -05:00
parent 2779e13692
commit c8c40f1682
1 changed files with 13 additions and 1 deletions

View File

@ -18,6 +18,18 @@ def _text_parse_uid(text):
res = re.sub("<@%s(.*?)>" % uid, "@%s" % user.user(), res)
return res
def _text_parse_channel(text):
res = text
for channel in re.findall("<#(.*?)>", text):
(chid, name) = channel.split("|")
res = re.sub("<#%s(.*?)>" % chid, "#%s" % name, res)
return res
def _text_parse_tags(text):
text = _text_parse_uid(text)
text = _text_parse_channel(text)
return text
class Message:
@ -33,7 +45,7 @@ class Message:
def __str__(self):
lines = []
for line in self.__text:
line = _text_parse_uid(line)
line = _text_parse_tags(line)
lines += [ "" ] + textwrap.wrap(line)
text = "\n ".join(lines)
time = self.__time.strftime("%I:%M:%S %p")