diff options
author | Ryan Huber <rhuber@gmail.com> | 2014-12-09 18:08:52 -0800 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2014-12-09 18:08:52 -0800 |
commit | 5b8de062ef9c24f158d8ab57aea095c8d238e0ac (patch) | |
tree | ac2b996f0d924e6092b81a2b0b6462734dfb10a4 | |
parent | 8f5f1e25b4161312f7af10ebcc7cbc1c3dceaefe (diff) | |
download | wee-slack-5b8de062ef9c24f158d8ab57aea095c8d238e0ac.tar.gz |
handle extra chars after name
-rw-r--r-- | wee_slack.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/wee_slack.py b/wee_slack.py index 4ccf900..f072b19 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -355,10 +355,15 @@ class Channel(SlackThing): def linkify_text(self, message): message = message.split(' ') for item in enumerate(message): - if item[1].startswith('@') and self.server.users.find(item[1]): - message[item[0]] = "<@{}>".format(self.server.users.find(item[1]).identifier) + if item[1].startswith('@'): + named = re.match('.*[@#](\w+)(\W*)', item[1]).groups() + if self.server.users.find(named[0]): + message[item[0]] = "<@{}>{}".format(self.server.users.find(named[0]).identifier, named[1]) if item[1].startswith('#') and self.server.channels.find(item[1]): - message[item[0]] = "<#{}>".format(self.server.channels.find(item[1]).identifier) + named = re.match('.*[@#](\w+)(\W*)', item[1]).groups() + if self.server.channels.find(named[0]): + message[item[0]] = "<#{}>{}".format(self.server.channels.find(named[0]).identifier, named[1]) + dbg(message) return " ".join(message) def set_topic(self, topic): topic = topic.encode('ascii', 'ignore') |