lib/scamp/matcher.rb in scamp-0.0.3 vs lib/scamp/matcher.rb in scamp-0.0.4
- old
+ new
@@ -41,22 +41,14 @@
action_run.matches = match if match
action_run.run
end
def conditions_satisfied_by(msg)
- # bot.logger.warn "Need to take into account nick, channel and regexps at #{__FILE__}:#{__LINE__}"
- bot.logger.info "Checking message against #{conditions.inspect}"
+ bot.logger.debug "Checking message against #{conditions.inspect}"
- # nick
- # channel name
- # nick regex
- # channel regex
-
- #{"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.
+ # cond is the int or string value.
conditions.each do |item, cond|
bot.logger.debug "Checking #{item} against #{cond}"
bot.logger.debug "msg is #{msg.inspect}"
if cond.is_a? Integer
# bot.logger.debug "item is #{msg[{:channel => :room_id, :user => :user_id}[item]]}"
@@ -67,12 +59,9 @@
return false unless bot.channel_name_for(msg[:room_id]) == cond
when :user
return false unless bot.username_for(msg[:user_id]) == cond
end
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