Class: SlackRubyBot::Hooks::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/slack-ruby-bot/hooks/message.rb

Instance Method Summary collapse

Instance Method Details

#call(client, data) ⇒ Object



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

def call(client, data)
  return if !client.allow_message_loops? && client.message_to_self?(data)
  return if !client.allow_bot_messages? && client.bot_message?(data)

  prepare!(data)

  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