diff options
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/wee_slack.py b/wee_slack.py index 414f6ca..a7c80f2 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -536,16 +536,17 @@ class Channel(object): def linkify_text(self, message): message = message.split(' ') for item in enumerate(message): - if item[1].startswith('@') and len(item[1]) > 1: - named = re.match('.*[@#]([\w.]+\w)(\W*)', item[1]).groups() - if named[0] in ["group", "channel", "here"]: - message[item[0]] = "<!{}>".format(named[0]) - 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]): - 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[0], named[1]) + targets = re.match('.*([@#])([\w.]+\w)(\W*)', item[1]) + if targets and targets.groups()[0] == '@': + named = targets.groups() + if named[1] in ["group", "channel", "here"]: + message[item[0]] = "<!{}>".format(named[1]) + if self.server.users.find(named[1]): + message[item[0]] = "<@{}>{}".format(self.server.users.find(named[1]).identifier, named[2]) + if targets and targets.groups()[0] == '#': + named = targets.groups() + if self.server.channels.find(named[1]): + message[item[0]] = "<#{}|{}>{}".format(self.server.channels.find(named[1]).identifier, named[1], named[2]) dbg(message) return " ".join(message) |