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

Match doesn't allow bot to be addressed by name #191

Open
olingern opened this issue Jul 11, 2018 · 4 comments
Open

Match doesn't allow bot to be addressed by name #191

olingern opened this issue Jul 11, 2018 · 4 comments
Labels

Comments

@olingern
Copy link

olingern commented Jul 11, 2018

match should still allow a bot to be addressed by name in a channel or by private message:

  • @bot ping should be possible, however even updating the regex does not fix, i.e.

    match(/^@botname ping$/)

Example Code:

class PongBot < SlackRubyBot::Bot
  match('/ping$/') do |client, data, match|
    client.say(text: 'pong', channel: data.channel)
  end
end

PongBot.run
@dblock dblock added the bug? label Jul 11, 2018
@dblock
Copy link
Collaborator

dblock commented Jul 11, 2018

Not sure why that doesn't work. Try something like match(/^(?<bot>\S*)[\s]*(?<expression>.*)$/), which is the matcher for unknown commands?

@olingern
Copy link
Author

@dblock Thanks for the suggestion! That indeed worked.

I also noticed that using match do not populate the bot's help command. If using match and I want to provide syntax / all the commands for a bot -- will I need to manually do that?

@dblock
Copy link
Collaborator

dblock commented Jul 13, 2018

I think so and we should document how to do that. Maybe take a look at how that's implemented and we can move the code from command to match so that it can document all commands?

@olingern
Copy link
Author

@dblock I see. I have a long weekend coming up, so I'll give this a look and see if I can open an PR.

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

No branches or pull requests

2 participants