class TelegramMeetupBot::CommandsHandler

Attributes

botan[R]
command[R]
messenger[R]
mode[R]

Public Class Methods

new(args) click to toggle source
# 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

Public Instance Methods

process() click to toggle source
# 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

Private Instance Methods

build_parser(args) click to toggle source
# File lib/telegram_meetup_bot/commands_handler.rb, line 23
def build_parser(args)
  if args[:message]
    @mode = :send
    MessageParser.new(args[:message])
  elsif args[:callback_query]
    @mode = :edit
    CallbackQueryParser.new(args[:callback_query])
  end
end