Class: Discordrb::Events::MessageEventHandler
- Inherits:
-
EventHandler
- Object
- EventHandler
- Discordrb::Events::MessageEventHandler
- Defined in:
- lib/discordrb/events/message.rb
Direct Known Subclasses
Instance Method Summary collapse
Methods inherited from EventHandler
#initialize, #match, #matches_all
Constructor Details
This class inherits a constructor from Discordrb::Events::EventHandler
Instance Method Details
#matches?(event) ⇒ Boolean
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/discordrb/events/message.rb', line 23 def matches?(event) # Check for the proper event type return false unless event.is_a? MessageEvent return [ matches_all(@attributes[:starting_with], event.content) { |a,e| e.start_with? a }, matches_all(@attributes[:ending_with], event.content) { |a,e| e.end_with? a }, matches_all(@attributes[:containing], event.content) { |a,e| e.include? a }, matches_all(@attributes[:in], event.channel) do |a,e| if a.is_a? String # Make sure to remove the "#" from channel names in case it was specified a.gsub('#', '') == e.name elsif a.is_a? Fixnum a == e.id else a == e end end, matches_all(@attributes[:from], event.) do |a,e| if a.is_a? String a == e.name elsif a.is_a? Fixnum a == e.id else a == e end end, matches_all(@attributes[:with_text], event.content) { |a,e| e == a }, matches_all(@attributes[:after], event.) { |a,e| a > e }, matches_all(@attributes[:before], event.) { |a,e| a < e } ].reduce(true, &:&) end |