attr_reader :raw_trigger, :raw_replies
class ::Reply
- attr_reader :act, :reply, :pct, :range
+ attr_reader :act, :reply, :pct
+ attr_accessor :range
attr_reader :author, :date, :channel
attr_writer :date
end
@trigger = [act]
if rex.sub!(%r@^([/!])(.*)\1$@, '\2')
- @trigger << Regexp.new(rex)
+ @trigger << Regexp.new(rex, true)
else
- @trigger << Regexp.new(/\b#{Regexp.escape(rex)}\b/u)
+ rex.sub!(/^(["'])(.*)\1$/, '\2')
+ @trigger << Regexp.new(/\b#{Regexp.escape(rex)}\b/ui)
end
end
return unless PrivMessage === m
debug "testing #{m} for reactions"
return if @reactions.empty?
- wanted = @reactions.find { |react|
- react === m
- }
- return unless wanted
- match = wanted === m
+ candidates = @reactions.map { |react|
+ blob = react === m
+ blob ? [blob, react] : nil
+ }.compact
+ return if candidates.empty?
+ match, wanted = candidates.sort { |m1, m2|
+ m1.first[0].length <=> m2.first[0].length
+ }.last
matched = match[0]
stuff = match.post_match.strip
target, what = stuff.split(/\s+/, 2)
def find_reaction(trigger)
@reactions.find { |react|
- react.raw_trigger == trigger
+ react.raw_trigger.downcase == trigger.downcase
}
end