lib/slack-ruby-bot/config.rb in slack-ruby-bot-0.4.5 vs lib/slack-ruby-bot/config.rb in slack-ruby-bot-0.5.0
- old
+ new
@@ -8,15 +8,33 @@
attr_accessor :user
attr_accessor :user_id
attr_accessor :team
attr_accessor :team_id
attr_accessor :allow_message_loops
+ attr_accessor :send_gifs
- def names
- [user, aliases, "<@#{user_id.downcase}>", "<@#{user_id.downcase}>:", "#{user}:"].compact.flatten
+ def allow_message_loops?
+ allow_message_loops
end
- def name?(name)
- name && names.include?(name.downcase)
+ def send_gifs?
+ v = boolean_from_env('SLACK_RUBY_BOT_SEND_GIFS')
+ v.nil? ? (send_gifs.nil? || send_gifs) : v
+ end
+
+ private
+
+ def boolean_from_env(key)
+ value = ENV[key]
+ case value
+ when nil
+ nil
+ when 0, 'false', 'no'
+ false
+ when 1, 'true', 'yes'
+ true
+ else
+ fail ArgumentError, "Invalid value for #{key}: #{value}."
+ end
end
end
end