Skip to content
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

Support a generic callback_mention on user mentions #550

Closed
azlekov opened this issue Nov 19, 2015 · 6 comments
Closed

Support a generic callback_mention on user mentions #550

azlekov opened this issue Nov 19, 2015 · 6 comments

Comments

@azlekov
Copy link
Contributor

azlekov commented Nov 19, 2015

Hello, yesterday I try Hubot with Slack integration and when I mention robot and write some command with @hubot some command Bot responses. Today I try this with Err and nothing happened. I take a look in Slack backend and some debug log from Errbot and figure that there's chance to add mention functionality:

https://github.com/errbotio/errbot/blob/master/errbot/backends/slack.py#L335

...
if 'message' in event:
    text = event['message']['text']
    user = event['message'].get('user', event.get('bot_id'))
else:
    text = event['text']
    user = event.get('user', event.get('bot_id'))
...
# Or get only first word
for word in text.split(' '):
    # Or check only if word start with '<@'
    if word.startswith('<') or word.startswith('@') or word.startswith('#'):
        username, userid, channelname, channelid = self.extract_identifiers_from_string(word.replace(':', ''))
        if(self.bot_identifier.userid == userid):
            self.mention = True
...

Here mention setting must be set and must be evaluated and checked in: https://github.com/errbotio/errbot/blob/master/errbot/errBot.py#L234

Can someone give me an idea how to pass it from backend to ErrBot.py? Some elegant way which won't break Errbot dev principles.

Thanks!

PS. Some workaround is to debug errbot and get bot id in format <@U*********>. Then add @U********* to BOT_ALT_PREFIXES variable

@gbin
Copy link
Member

gbin commented Nov 20, 2015

I would say we could have a callback_mention(self, message: message, mentioned_people: Sequence[Identifier]) signature in the plugin api ?

basically anytime somebody gets mentionned, the plugins get notified with the message and the list of identifiers that were mentioned ?

@azlekov
Copy link
Contributor Author

azlekov commented Nov 24, 2015

Callback in base backend class or?
And by anytime you mean check every word if matches some id of person in room? If message is huge and there are many people in room this can be little heavy. What do you think?

@gbin
Copy link
Member

gbin commented Nov 24, 2015

I was thinking about a callback in BotPlugin, if you don't implement it, it won't do anything, if you implement it you can get the notifications and check against the identity of the bot if the bot was mentioned

@azlekov
Copy link
Contributor Author

azlekov commented Nov 26, 2015

Ah, I saw there's way to get Bot identifier from BotPlugin, so these days I can implement it.
Thanks for the feedback and I suppose we continue our discussion on the pull request. I will close this issue with the request. :)

@gbin gbin changed the title @ mention bot in Slack Support a generic callback_mention on user mentions Dec 3, 2015
@sijis
Copy link
Contributor

sijis commented Dec 7, 2015

@L3K0V Does this change in your config.py help?

I have the following below using a Slack backend and this tends to work for us:
>> hubot: some command

BOT_ALT_PREFIXES = ('hubot',)
BOT_ALT_PREFIX_SEPARATORS = (':', ',')
BOT_ALT_PREFIX_CASEINSENSITIVE = True

Out of curiosity, i did add BOT_ALT_PREFIXES and added '@hubot' but it made no difference.

@azlekov
Copy link
Contributor Author

azlekov commented Dec 7, 2015

Yes your configuration will work, but the idea was to have ability to
mention the robot, by some real robot name in chatroom :D. Adding @ will no
work because mentions are part of the message text and slack covert the
names to some IDs. Errbot doesn't parse message text and check if there are
some ids. Not yet. I will add support soon i guess.

The workaround I propose is working with @ but in Errbot config you must
put converted string from slack, looking like <@some_id>. You can sniff
it using debug and checking a bot message.

On Mon, 7 Dec 2015 07:00 Sijis Aviles notifications@github.com wrote:

@L3K0V https://github.com/L3K0V Does this change in your config.py help?

I have the following below using a Slack backend and this tends to work
for us:

hubot: some command

BOT_ALT_PREFIXES = ('hubot',)
BOT_ALT_PREFIX_SEPARATORS = (':', ',')
BOT_ALT_PREFIX_CASEINSENSITIVE = True

Out of curiosity, i did add BOT_ALT_PREFIXES and added '@hubot
https://github.com/hubot' but it made no difference.


Reply to this email directly or view it on GitHub
#550 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants