diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-03-25 23:31:14 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-03-25 23:31:14 +0100 |
commit | 8ddc8ed81f1f5065705c68d2abda5804319ff981 (patch) | |
tree | a339d4f1d971e05109ca553bb88997c2a8944f2c /lib/rbot | |
parent | 7ab65c2443f44df753b3b6d2b186b5fd0d17857c (diff) |
messagemapper: include defaults in options
This change allows the use of :defaults in maps to define values for
parameters which are not actually present in the map itself.
We also move the initialization further down, to skip it in case of
early returns.
Diffstat (limited to 'lib/rbot')
-rw-r--r-- | lib/rbot/messagemapper.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/rbot/messagemapper.rb b/lib/rbot/messagemapper.rb index 1162a3a2..c1691aff 100644 --- a/lib/rbot/messagemapper.rb +++ b/lib/rbot/messagemapper.rb @@ -535,8 +535,6 @@ class Bot return nil, "template #{@template} is not configured for private messages" if @options.has_key?(:private) && !@options[:private] && m.private? return nil, "template #{@template} is not configured for public messages" if @options.has_key?(:public) && !@options[:public] && !m.private? - options = {} - matching = @regexp.match(m.message) return nil, "#{m.message.inspect} doesn't match #{@template} (#{@regexp})" unless matching return nil, "#{m.message.inspect} only matches #{@template} (#{@regexp}) partially: #{matching[0].inspect}" unless matching[0] == m.message @@ -545,6 +543,8 @@ class Bot debug "#{m.message.inspect} matched #{@regexp} with #{debug_match}" debug "Associating #{debug_match} with dyn items #{@dyn_items.join(', ')}" + options = @defaults.dup + @dyn_items.each_with_index { |it, i| next if i == 0 item = it.name |