aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorcalve <calvinh34@gmail.com>2015-10-28 11:57:58 +0100
committercalve <calvinh34@gmail.com>2016-01-04 11:11:19 +0100
commit8276125ff03662d4b40a9027baa5fa4428d06dc1 (patch)
tree0a804e8311b6aa28c716d842224cb1bfe87d155c /wee_slack.py
parent0f4ec71a6cf642e149a11e3cfcf97de5d55098f1 (diff)
downloadwee-slack-8276125ff03662d4b40a9027baa5fa4428d06dc1.tar.gz
unfurl regexp for all cases
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py
index e9733ef..30f25fc 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1674,8 +1674,12 @@ def unfurl_refs(text, ignore_alt_text=False):
input : <@U096Q7CQM|someuser> has joined the channel
ouput : someuser has joined the channel
"""
- # Find all string enclosed by <> and starting with an ``@`` on a ``#``
- matches = re.findall(r"(<[@#](?:\S*)>)", text)
+ # Find all strings enclosed by <>
+ # - <https://example.com|example with spaces>
+ # - <#C2147483705|#otherchannel>
+ # - <@U2147483697|@othernick>
+ # Test patterns lives in ./_pytest/test_unfurl.py
+ matches = re.findall(r"(<[@#]?(?:[^<]*)>)", text)
for m in matches:
# Replace them with human readable strings
text = text.replace(m, unfurl_ref(m[1:-1], ignore_alt_text))