lib/hipbot/reaction.rb in hipbot-1.0.3 vs lib/hipbot/reaction.rb in hipbot-1.0.4
- old
+ new
@@ -32,14 +32,10 @@
def global?
!!options[:global]
end
- def inspect
- "#<Hipbot::Reaction #{options}>"
- end
-
def plugin_name
plugin.name.demodulize
end
def match_with message
@@ -51,14 +47,20 @@
end
attr_cache :readable_command do
regexps.map(&:source).join(' or ').gsub(/\^|\\z|\$|\\/, '')
end
+ delegate :to_s, to: :readable_command
attr_cache :regexps do
- Array(options[:regexps]).map do |regexp|
- Regexp.new(regexp.source, Regexp::IGNORECASE)
+ regexps = Array(options[:regexps])
+ if Hipbot.configuration.case_insensitive
+ regexps.map do |regexp|
+ Regexp.new(regexp.source, Regexp::IGNORECASE)
+ end
+ else
+ regexps
end
end
attr_cache :rooms do
replace_symbols(options[:room], Hipbot.rooms)
@@ -69,9 +71,9 @@
end
protected
def replace_symbols values, replacements_hash
- Array(values).flat_map{ |v| replacements_hash[v] || v }.map(&:to_s)
+ Array(values).flat_map{ |v| replacements_hash[v] || v }.uniq
end
end
end