Class: VkCozy::Text

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

Instance Method Summary collapse

Constructor Details

#initialize(regex, **kwargs) ⇒ Text

Returns a new instance of Text.



51
52
53
54
# File 'lib/vk_cozy/framework/labeler/filters/filters.rb', line 51

def initialize(regex, **kwargs)
  @regex = regex
  @raw = kwargs
end

Instance Method Details

#check_bot(event) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/vk_cozy/framework/labeler/filters/filters.rb', line 72

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



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/vk_cozy/framework/labeler/filters/filters.rb', line 56

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