lib/scamp/matcher.rb in scamp-0.0.1 vs lib/scamp/matcher.rb in scamp-0.0.2
- old
+ new
@@ -29,11 +29,11 @@
if trigger.is_a? String
return true if trigger == message_text
elsif trigger.is_a? Regexp
return trigger.match message_text
else
- STDERR.puts "Don't know what to do with #{trigger.inspect} at #{__FILE__}:#{__LINE__}"
+ bot.logger.warn "Don't know what to do with #{trigger.inspect} at #{__FILE__}:#{__LINE__}"
end
false
end
def run(msg, match = nil)
@@ -41,11 +41,12 @@
action_run.matches = match if match
action_run.run
end
def conditions_satisfied_by(msg)
- # STDERR.puts "Need to take into account nick, channel and regexps at #{__FILE__}:#{__LINE__}"
+ # bot.logger.warn "Need to take into account nick, channel and regexps at #{__FILE__}:#{__LINE__}"
+ bot.logger.info "Checking message against #{conditions.inspect}"
# nick
# channel name
# nick regex
# channel regex
@@ -53,27 +54,27 @@
#{"room_id":1,"created_at":"2009-12-01 23:44:40","body":"hello","id":1,"user_id":1,"type":"TextMessage"}
# item will be :nick or :channel
# cond is the regex, int or string value.
conditions.each do |item, cond|
- STDERR.puts "Checking #{item} against #{cond}"
- puts "msg is #{msg.inspect}"
+ bot.logger.debug "Checking #{item} against #{cond}"
+ bot.logger.debug "msg is #{msg.inspect}"
if cond.is_a? Integer
- # puts "item is #{msg[{:channel => :room_id, :user => :user_id}[item]]}"
+ # bot.logger.debug "item is #{msg[{:channel => :room_id, :user => :user_id}[item]]}"
return false unless msg[{:channel => :room_id, :user => :user_id}[item]] == cond
elsif cond.is_a? String
case item
when :channel
return false unless bot.channel_name_for(msg[:room_id]) == cond
when :user
return false unless bot.username_for(msg[:user_id]) == cond
end
- STDERR.puts "Don't know how to deal with a match item of #{item}, cond #{cond}"
+ bot.logger.error "Don't know how to deal with a match item of #{item}, cond #{cond}"
elsif cond.is_a? Regexp
return false
return false unless msg[item].match(cond)
end
end
true
end
end
-end
\ No newline at end of file
+end