Class: Filter::Text

Inherits:
BaseFilter show all
Defined in:
lib/vk_cozy/framework/labeler/filters/filters.rb

Instance Method Summary collapse

Constructor Details

#initialize(regex) ⇒ Text

Returns a new instance of Text.



57
58
59
# File 'lib/vk_cozy/framework/labeler/filters/filters.rb', line 57

def initialize(regex)
  @regex = regex
end

Instance Method Details

#check_bot(event) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/vk_cozy/framework/labeler/filters/filters.rb', line 77

def check_bot(event)
  if event.type == VkCozy::BotEventType::MESSAGE_NEW
    if event.message.text == @regex
      return true
    else
      return false
    end
  else
    return false
  end
end

#check_user(event) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/vk_cozy/framework/labeler/filters/filters.rb', line 61

def check_user(event)
  if event.type == VkCozy::UserEventType::MESSAGE_NEW

    if event.from_me
      return false
    end
    if event.text == @regex
      return true
    else
      return false
    end
  else
    return false
  end
end