aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2019-04-02 20:46:56 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2019-04-02 20:46:56 +0200
commit32d63857a0f7f00fc462f9069e32f22d803985fe (patch)
tree7edcb8026c74680617b90f7facef929d27577324
parent55ac43c0254ec6b1fdad6841104594f0645aaea1 (diff)
downloadwee-slack-32d63857a0f7f00fc462f9069e32f22d803985fe.tar.gz
Keep text directly after @channel/group/here when linkifying
Previously, when writing e.g. `@channel: test` the colon would be lost.
-rw-r--r--_pytest/test_linkifytext.py16
-rw-r--r--wee_slack.py2
2 files changed, 17 insertions, 1 deletions
diff --git a/_pytest/test_linkifytext.py b/_pytest/test_linkifytext.py
index c8489be..da672dc 100644
--- a/_pytest/test_linkifytext.py
+++ b/_pytest/test_linkifytext.py
@@ -58,3 +58,19 @@ def test_linkifytext_names_with_apostrophe(realish_eventrouter):
text = linkify_text('@O\'Connor: my test message', team, channel)
assert text == '@O\'Connor: my test message'
+
+def test_linkifytext_at_channel(realish_eventrouter):
+ team = realish_eventrouter.teams.values()[0]
+ channel = team.channels.values()[0]
+
+ text = linkify_text('@channel: my test message', team, channel)
+
+ assert text == '<!channel>: my test message'
+
+def test_linkifytext_channel(realish_eventrouter):
+ team = realish_eventrouter.teams.values()[0]
+ channel = team.channels.values()[0]
+
+ text = linkify_text('#{}: my test message'.format(channel.name), team, channel)
+
+ assert text == '<#{}|{}>: my test message'.format(channel.id, channel.name)
diff --git a/wee_slack.py b/wee_slack.py
index dd79234..fbde84e 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2970,7 +2970,7 @@ def linkify_text(message, team, channel):
if targets and targets.groups()[0] == '@':
named = targets.groups()
if named[1] in ["group", "channel", "here"]:
- message[item[0]] = "<!{}>".format(named[1])
+ message[item[0]] = "<!{}>{}".format(named[1], named[2])
else:
try:
if usernames[named[1]]: