Module: SlackRubyBot::Hooks::Message

Extended by:
Base
Included in:
Server
Defined in:
lib/slack-ruby-bot/hooks/message.rb

Instance Method Summary collapse

Methods included from Base

included

Instance Method Details

#message(client, data) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/slack-ruby-bot/hooks/message.rb', line 6

def message(client, data)
  data = Hashie::Mash.new(data)
  return if !SlackRubyBot::Config.allow_message_loops? && (client.self && client.self['id'] == data.user)
  data.text.strip! if data.text
  result = child_command_classes.detect { |d| d.invoke(client, data) }
  result ||= built_in_command_classes.detect { |d| d.invoke(client, data) }
  result ||= SlackRubyBot::Commands::Unknown.tap { |d| d.invoke(client, data) }
  result
end