lib/scamp/matcher.rb in scamp-1.1.0 vs lib/scamp/matcher.rb in scamp-1.2.0

- old
+ new

@@ -24,11 +24,11 @@ end private def triggered_by(message_text) - if message_text && required_prefix + if message_text && required_prefix message_text = handle_prefix(message_text) return false unless message_text end if trigger.is_a? String return true if trigger == message_text @@ -65,11 +65,11 @@ action_run.run end def conditions_satisfied_by(msg) bot.logger.debug "Checking message against #{conditions.inspect}" - + # item will be :user or :room # 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}" @@ -87,9 +87,16 @@ elsif cond.is_a? Array case item when :room, :rooms return cond.select {|e| e.is_a? Integer }.include?(msg[{:room => :room_id}[item]]) || cond.select {|e| e.is_a? String }.include?(bot.room_name_for(msg[:room_id])) + end + bot.logger.error "Don't know how to deal with a match item of #{item}, cond #{cond}" + elsif cond.is_a? Symbol + case item + when :type + return (cond == :text && msg[:type] == "TextMessage") || + (cond == :paste && msg[:type] == "PasteMessage") end bot.logger.error "Don't know how to deal with a match item of #{item}, cond #{cond}" end end true