Sha256: 3fe41b265bb71a074fc123a0dec6d0bc74abb03076282d79c6fda3968cdea416
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
module SlackRubyBot module Hooks module Message extend Base 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 private # # All commands. # # @return [Array] Descendants of SlackRubyBot::Commands::Base. # def command_classes SlackRubyBot::Commands::Base.descendants end # # All non-built-in, ie. custom commands. # # @return [Array] Non-built-in descendants of SlackRubyBot::Commands::Base. # def child_command_classes command_classes.reject do |k| k.name && k.name.starts_with?('SlackRubyBot::Commands::') end end # # All built-in commands. # # @return [Array] Built-in descendants of SlackRubyBot::Commands::Base. # def built_in_command_classes command_classes.select do |k| k.name && k.name.starts_with?('SlackRubyBot::Commands::') && k != SlackRubyBot::Commands::Unknown end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slack-ruby-bot-0.4.5 | lib/slack-ruby-bot/hooks/message.rb |