Class: TelegramBot::CommandMatcher

Inherits:
Matcher
  • Object
show all
Defined in:
lib/telegram_bot/matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ CommandMatcher

Returns a new instance of CommandMatcher.



38
39
40
# File 'lib/telegram_bot/matcher.rb', line 38

def initialize(command)
  @command = command
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



36
37
38
# File 'lib/telegram_bot/matcher.rb', line 36

def command
  @command
end

Instance Method Details

#===(msg) ⇒ Object



42
43
44
# File 'lib/telegram_bot/matcher.rb', line 42

def ===(msg)
  msg.type == :text and msg.text.start_with?("/#{@command}")
end

#arguments(msg) ⇒ Object



46
47
48
# File 'lib/telegram_bot/matcher.rb', line 46

def arguments(msg)
  msg.text.split[1..-1]
end