Class: TelegramBot::CommandMatcher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Matcher

#env, #extend_env

Constructor Details

#initialize(command) ⇒ CommandMatcher

Returns a new instance of CommandMatcher.



62
63
64
# File 'lib/telegram_bot/matcher.rb', line 62

def initialize(command)
  @command = command
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



60
61
62
# File 'lib/telegram_bot/matcher.rb', line 60

def command
  @command
end

Instance Method Details

#===(msg) ⇒ Object



66
67
68
# File 'lib/telegram_bot/matcher.rb', line 66

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

#arguments(msg) ⇒ Object



70
71
72
# File 'lib/telegram_bot/matcher.rb', line 70

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