Class: TelegramMeetupBot::CommandsHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/telegram_meetup_bot/commands_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CommandsHandler

Returns a new instance of CommandsHandler.



5
6
7
8
9
10
# File 'lib/telegram_meetup_bot/commands_handler.rb', line 5

def initialize(args)
  parser = build_parser(args)
  @command = TelegramMeetupBot::Commands::Factory.build(parser)
  @messenger = args.fetch(:messenger)
  @botan = args[:botan]
end

Instance Attribute Details

#botanObject (readonly)

Returns the value of attribute botan.



3
4
5
# File 'lib/telegram_meetup_bot/commands_handler.rb', line 3

def botan
  @botan
end

#commandObject (readonly)

Returns the value of attribute command.



3
4
5
# File 'lib/telegram_meetup_bot/commands_handler.rb', line 3

def command
  @command
end

#messengerObject (readonly)

Returns the value of attribute messenger.



3
4
5
# File 'lib/telegram_meetup_bot/commands_handler.rb', line 3

def messenger
  @messenger
end

#modeObject (readonly)

Returns the value of attribute mode.



3
4
5
# File 'lib/telegram_meetup_bot/commands_handler.rb', line 3

def mode
  @mode
end

Instance Method Details

#processObject



12
13
14
15
16
17
18
19
# File 'lib/telegram_meetup_bot/commands_handler.rb', line 12

def process
  if command && mode == :send
    messenger.send_text(*command.exec)
    botan.track(command.command) if botan
  elsif command && mode == :edit
    messenger.edit_text(*command.exec)
  end
end