Class: VkCozy::Bothandler

Inherits:
Object
  • Object
show all
Defined in:
lib/vk_cozy/framework/labeler/bot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filter, func, stop: true) ⇒ Bothandler

Returns a new instance of Bothandler.



6
7
8
9
10
# File 'lib/vk_cozy/framework/labeler/bot.rb', line 6

def initialize(filter, func, stop: true)
  @stop = stop
  @filter = filter
  @func = func
end

Instance Attribute Details

#stopObject (readonly)

Returns the value of attribute stop.



4
5
6
# File 'lib/vk_cozy/framework/labeler/bot.rb', line 4

def stop
  @stop
end

Instance Method Details

#check(event) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vk_cozy/framework/labeler/bot.rb', line 12

def check(event)
  check_bot = @filter.check_bot(event)
  if check_bot
    if check_bot.is_a?(Symbol)
      return true
    elsif check_bot.is_a?(Hash)
      @func.call(event, check_bot)
    else
      @func.call(event)
    end
    if @stop
      return true
    end
  end
end