slack-ruby-bot
slack-ruby-bot copied to clipboard
Match doesn't allow bot to be addressed by name
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
Not sure why that doesn't work. Try something like match(/^(?<bot>\S*)[\s]*(?<expression>.*)$/)
, which is the matcher for unknown commands?
@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?
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?
@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.