From 5b8de062ef9c24f158d8ab57aea095c8d238e0ac Mon Sep 17 00:00:00 2001 From: Ryan Huber Date: Tue, 9 Dec 2014 18:08:52 -0800 Subject: handle extra chars after name --- wee_slack.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'wee_slack.py') 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') -- cgit