From 6f9ad0ae1a89404246877bfeffe9ff4d18745b1a Mon Sep 17 00:00:00 2001 From: Yaohan Chen Date: Tue, 24 Jun 2008 13:45:56 -0400 Subject: allow multi-line (artificial) messages be delegated and handled --- lib/rbot/message.rb | 3 ++- lib/rbot/messagemapper.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/rbot/message.rb b/lib/rbot/message.rb index 97e3673a..1fb68e20 100644 --- a/lib/rbot/message.rb +++ b/lib/rbot/message.rb @@ -328,7 +328,8 @@ module Irc # free splitting for plugins @params = @message.dup - if @params.gsub!(/^\s*(\S+)[\s$]*/, "") + # Created messges (such as by fake_message) can contain multiple lines + if @params.gsub!(/\A\s*(\S+)[\s$]*/m, "") @plugin = $1.downcase @params = nil unless @params.length > 0 end diff --git a/lib/rbot/messagemapper.rb b/lib/rbot/messagemapper.rb index dd43e27c..b6125538 100644 --- a/lib/rbot/messagemapper.rb +++ b/lib/rbot/messagemapper.rb @@ -519,7 +519,8 @@ class Bot # debug "Delimited optionals: #{rx.inspect}" rx.gsub!(/(?:\\ )+/, "\\s+") # debug "Corrected spaces: #{rx.inspect}" - @regexp = Regexp.new("^#{rx}$") + # Created message (such as by fake_message) can contain multiple lines + @regexp = /\A#{rx}\z/m end # Recognize the provided string components, returning a hash of -- cgit v1.2.3