lib/slack-ruby-bot/commands/base.rb in slack-ruby-bot-0.4.4 vs lib/slack-ruby-bot/commands/base.rb in slack-ruby-bot-0.4.5
- old
+ new
@@ -52,14 +52,15 @@
end
end
def self.invoke(client, data)
self.finalize_routes!
- expression = parse(data)
+ expression, text = parse(data)
called = false
routes.each_pair do |route, method|
match = route.match(expression)
+ match ||= route.match(text) if text
next unless match
next if match.names.include?('bot') && !SlackRubyBot.config.name?(match['bot'])
called = true
if method
method.call(client, data, match)
@@ -86,10 +87,10 @@
SlackRubyBot.config.names.each do |name|
text.downcase.tap do |td|
return text if td == name || td.starts_with?("#{name} ")
end
end
- "#{SlackRubyBot.config.user} #{text}"
+ ["#{SlackRubyBot.config.user} #{text}", text]
end
def self.finalize_routes!
return if self.routes && self.routes.any?
command default_command_name