Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support matching against a certain type of msg type (text or paste).
  • Loading branch information
mheffner committed Oct 11, 2013
1 parent ad298ee commit 0792b6e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/scamp/matcher.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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|
Expand All @@ -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
Expand Down

0 comments on commit 0792b6e

Please sign in to comment.