lib/slack-ruby-bot/client.rb in slack-ruby-bot-0.8.2 vs lib/slack-ruby-bot/client.rb in slack-ruby-bot-0.9.0

- old
+ new

@@ -5,11 +5,11 @@ attr_accessor :send_gifs def initialize(attrs = {}) super(attrs) @aliases = attrs[:aliases] - @send_gifs = attrs.key?(:send_gifs) ? !!attrs[:send_gifs] : true + @send_gifs = attrs[:send_gifs] end def names [ SlackRubyBot::Config.user, @@ -28,11 +28,12 @@ def name?(name) name && names.include?(name.downcase) end def send_gifs? - send_gifs + return false unless defined?(Giphy) + send_gifs.nil? ? SlackRubyBot::Config.send_gifs? : send_gifs end def name SlackRubyBot.config.user || (self.self && self.self.name) end @@ -50,10 +51,10 @@ gif = begin Giphy.random(keywords) rescue StandardError => e logger.warn "Giphy.random: #{e.message}" nil - end if SlackRubyBot::Config.send_gifs? && send_gifs? && keywords + end if keywords && send_gifs? text = [text, gif && gif.image_url.to_s].compact.join("\n") message({ text: text }.merge(options)) end end end