Parse channel tags to make them easier to read
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
2779e13692
commit
c8c40f1682
|
@ -18,6 +18,18 @@ def _text_parse_uid(text):
|
||||||
res = re.sub("<@%s(.*?)>" % uid, "@%s" % user.user(), res)
|
res = re.sub("<@%s(.*?)>" % uid, "@%s" % user.user(), res)
|
||||||
return 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:
|
class Message:
|
||||||
|
@ -33,7 +45,7 @@ class Message:
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
lines = []
|
lines = []
|
||||||
for line in self.__text:
|
for line in self.__text:
|
||||||
line = _text_parse_uid(line)
|
line = _text_parse_tags(line)
|
||||||
lines += [ "" ] + textwrap.wrap(line)
|
lines += [ "" ] + textwrap.wrap(line)
|
||||||
text = "\n ".join(lines)
|
text = "\n ".join(lines)
|
||||||
time = self.__time.strftime("%I:%M:%S %p")
|
time = self.__time.strftime("%I:%M:%S %p")
|
||||||
|
|
Loading…
Reference in New Issue