From 0792b6e7eba704318bd0b1cbd5c87e15902aee6a Mon Sep 17 00:00:00 2001 From: Mike Heffner Date: Fri, 11 Oct 2013 16:02:50 -0400 Subject: [PATCH] Support matching against a certain type of msg type (text or paste). --- lib/scamp/matcher.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/scamp/matcher.rb b/lib/scamp/matcher.rb index 81a43e5..2e0561d 100644 --- a/lib/scamp/matcher.rb +++ b/lib/scamp/matcher.rb @@ -26,7 +26,7 @@ def attempt(msg) 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 @@ -67,7 +67,7 @@ def run(msg, match = nil) 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| @@ -91,6 +91,13 @@ def conditions_satisfied_by(msg) 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