Open DanielPaque opened 7 years ago
This is a bit tricky. Depending on your slack team settings, typing botname and pressing tab in a channel or group will either put @botname
or botname:
. in the latter case, we want to filter the bot's name out before matching handlers.
That said.. maybe we should actually compile the username into the regular expression, rather than reading it at runtime? Or, perhaps we could append the captured username value to the string we match on, if the username isn't the bot's name. Or, maybe we can read the team settings and figure out whether to expect @botname
or botname:
.
I think it would make sense to append the username to the string if it doesn't match the bot's name. This is definitely an issue I would like to see resolved asap.
Any updates in this? It would be nice to at least exclude https:
so that we can respond when someone posts a url.
Hi,
the decorator
@respond_to
fails at messages containing a colon after the first word, e.g. "18:45"Example: The following method will not react at all to the message "18:45"
The following method should respond to any text while receiving the full message. However will receive only "45" as text, although the user sent "18:45"
So it seems that characters in front of the first colon are not transferred to the respont_to part. (An exception to this behavior is any string containing a whitespace before the colon)
I could pinpoint the problem to following line of code in slackbot/dispatcher.py:
self.AT_MESSAGE_MATCHER = re.compile(r'^(?:\<@(?P<atuser>\w+)\>:?||(?P<username>\w+):{})...)
See here for full code.This regex is used for two purposes:
The first purpose seems fine for me, the second one is causing the trouble.
I fixed the problem for me by deleting the username part in the regex. At first sight, this seems to work quite fine.
So maybe you should consider how to handle messages like "18:45".
Regards, Daniel