From 5e9d3794d7b8e333f4ea76041e899dd1a98c70c3 Mon Sep 17 00:00:00 2001 From: dblock Date: Fri, 29 Jan 2016 16:40:58 -0500 Subject: [PATCH] Fix #43: Issuing a bot command terminates bot. --- CHANGELOG.md | 1 + lib/slack-ruby-bot/bot.rb | 4 ++++ spec/slack-ruby-bot/commands/bot_message_spec.rb | 10 ++++++++++ 3 files changed, 15 insertions(+) create mode 100644 spec/slack-ruby-bot/commands/bot_message_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index ca7e2d8..d27158b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### 0.6.1 (Next) +* [#43](https://github.com/dblock/slack-ruby-bot/issues/43): Issuing a `bot` command terminates bot - [@dblock](https://github.com/dblock). * [#40](https://github.com/dblock/slack-ruby-bot/pull/40): Added `SlackRubyBot::Config.reset!` - [@accessd](https://github.com/accessd). * Your contribution here. diff --git a/lib/slack-ruby-bot/bot.rb b/lib/slack-ruby-bot/bot.rb index 3d556f8..4e7bb96 100644 --- a/lib/slack-ruby-bot/bot.rb +++ b/lib/slack-ruby-bot/bot.rb @@ -9,5 +9,9 @@ def self.run def self.instance SlackRubyBot::App.instance end + + def self.call(client, data, _match) + client.say(channel: data.channel, text: "Sorry <@#{data.user}>, I don't understand that command!", gif: 'idiot') + end end end diff --git a/spec/slack-ruby-bot/commands/bot_message_spec.rb b/spec/slack-ruby-bot/commands/bot_message_spec.rb new file mode 100644 index 0000000..f999d8a --- /dev/null +++ b/spec/slack-ruby-bot/commands/bot_message_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper' + +describe SlackRubyBot::Commands::Help do + def app + SlackRubyBot::App.new + end + it 'bot' do + expect(message: "#{SlackRubyBot.config.user} bot").to respond_with_slack_message("Sorry <@user>, I don't understand that command!") + end +end