hedwig-im / hedwig_slack

Slack Adapter for Hedwig
MIT License
46 stars 30 forks source link

Only hear when mentioned? #9

Open philipgiuliani opened 8 years ago

philipgiuliani commented 8 years ago

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 commented 8 years ago

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... :wink:

scrogson commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

@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 commented 7 years ago

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 commented 6 years ago

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?