-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errbot doesn't recognise you're talking to it when you use its name #86
Comments
@colincoghill @samhopwell Thank you both for offering fixes for this issue. For a bit of history, this function was brought directly over from the slack backend. After looking at it closer there are a few issues with it.
# convert BOT_ALT_PREFIXES to a list
try:
bot_prefixes = self.bot_config.BOT_ALT_PREFIXES.split(",")
except AttributeError:
bot_prefixes = list(self.bot_config.BOT_ALT_PREFIXES) I question if this code should be completely removed.
This means that if the slackv3 backend is going to process Would either or both of you be interested in taking a crack at implementing that? If you're interested in working on a solution together, there's the gitter errbot community channel that you could use to communicate directly. (timezones overlap permitting) |
I got the impression this was for during conversation, |
I suppose the difficult part here is that because slack uses the "userid" now, instead of the username, the thing errbot (core.py) is comparing against is the user id ("@U10234") instead of the original username, so case insensitivity isn't really helpful. We'd have to override process_message() which feels messy. |
I dug more into the code and you're quite right about the From what I can tell, the I also agree that trying to override
In the 2nd case, the notion of case sensitive/insensitive is a valid and useful feature. Especially when a backend other than slack is being used. I ended coming up with this as a way to update the alternate prefixes. Do you want to give it a try on your end? from errbot.backends.base import (
UserNotUniqueError,
UserDoesNotExistError,
)
def update_alternate_prefixes(self):
"""Converts BOT_ALT_PREFIXES to use the slack ID instead of name
Slack only acknowledges direct callouts `@username` in chat if referred
by using the ID of that user.
"""
# convert BOT_ALT_PREFIXES to a list
try:
bot_prefixes = self.bot_config.BOT_ALT_PREFIXES.split(",")
except AttributeError:
bot_prefixes = list(self.bot_config.BOT_ALT_PREFIXES)
converted_prefixes = []
for prefix in bot_prefixes:
try:
new_prefix = self.username_to_userid(prefix)
if new_prefix != prefix:
new_prefix = f"<@{new_prefix}>"
except UserDoesNotExistError as e:
new_prefix = prefix
log.warning('"%s" was not found: %s', prefix, str(e))
except UserNotUniqueError as e:
log.warning("Can't add prefix because multiple users were found using %s", prefix)
continue
if self.bot_config.BOT_ALT_PREFIX_CASEINSENSITIVE:
new_prefix = new_prefix.lower()
converted_prefixes.append(new_prefix)
self.bot_alt_prefixes = tuple(converted_prefixes)
log.debug(f"Converted bot_alt_prefixes: {self.bot_config.BOT_ALT_PREFIXES} to {self.bot_alt_prefixes}") |
We recently switched from the old slackclient to the slackv3 backend and it generally works pretty well, however:
when we try to issue errbot a command by mentioning it
@errbot help
instead of with the prefix!help
it doesn'trecognize that it's being spoken to and doesn't respond.
I think the fault is in line 173 of slackv3.py:
err-backend-slackv3/slackv3.py
Lines 164 to 175 in 240b176
If I change it to:
self.bot_alt_prefixes = tuple(x.lower() for x in converted_prefixes)
we can talk to errbot again.The text was updated successfully, but these errors were encountered: