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

Only hear when mentioned? #9

Open
philipgiuliani opened this issue Oct 2, 2016 · 6 comments
Open

Only hear when mentioned? #9

philipgiuliani opened this issue Oct 2, 2016 · 6 comments

Comments

@philipgiuliani
Copy link

philipgiuliani commented Oct 2, 2016

Its possible to only hear when the bot is mentioned unless in its own chat? This would only affect responders. I would be much nicer in slack to write @bot help instead of bot help.

@scrogson
Copy link
Member

scrogson commented Oct 2, 2016

I'm not at my computer so I can't confirm but, it might be possible by setting the aka to the pattern that slack uses for mentions: <@id|name>. The bot's id is currently stored in the adapter's state. I will be making some changes so that you'll have access to those things very easily. So stay tuned... 😉

@scrogson
Copy link
Member

scrogson commented Oct 3, 2016

Ok, was just able to verify this works:

config :alfred, Alfred.Robot,
  adapter: Hedwig.Adapters.Slack,
  token: System.get_env("SLACK_TOKEN"),
  name: "alfred",
  aka: "!|<@U2FC3P1PH>",
  responders: [...]

Now my bot will respond to alfred, !, or @alfred.

Hope that helps!

@philipgiuliani
Copy link
Author

Thank you @scrogson. Is the id of the slackbot always the same? Would it be ok to hardcode it?

What do you think about making this behaviour a standard? Maybe we could replace the <@BOTID> with the name of the bot, so the hedwig-im library would parse it as responder? I haven't looked how hedwig-im works, just over the slack adapter.

@scrogson
Copy link
Member

scrogson commented Oct 3, 2016

@philipgiuliani as far as I know, the bot's id doesn't change, so hardcoding in your config should be fine.

I've recently (yesterday) pushed code to Hedwig master that makes all responders into GenServers so I think it will be totally possible to send a message to all responders to rewrite the regexes with the new aka value.

@ivanovaleksey
Copy link

Hi guys, I was thinking about the same. What would be the correct solution for now?
Should I grab bot id somehow, or something have changed and there is more convenient method?

@wizonesolutions
Copy link

Re. the other part of the earlier question, is there a way to make the bot respond to unprefixed commands over DM but require the prefix otherwise?

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

No branches or pull requests

4 participants