Module: ActiveMatrix::Bot

Defined in:
lib/active_matrix/event_router.rb,
lib/active_matrix/bot.rb,
lib/active_matrix/bot/base.rb,
lib/active_matrix/bot/multi_instance_base.rb

Overview

Routing DSL for bots

Defined Under Namespace

Classes: Base, Instance, MultiInstanceBase

Constant Summary collapse

PARAMS_CONFIG =

rubocop:disable Style/MutableConstant Intended

{}

Class Method Summary collapse

Class Method Details

.parse_arguments!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/active_matrix/bot.rb', line 10

def parse_arguments!
  parser = OptionParser.new do |op|
    op.on('-s homeserver', 'Specify homeserver') { |val| PARAMS_CONFIG[:homeserver] = val }

    op.on('-T token', 'Token') { |val| PARAMS_CONFIG[:access_token] = val }
    op.on('-U username', 'Username') { |val| PARAMS_CONFIG[:username] = val }
    op.on('-P password', 'Password') { |val| PARAMS_CONFIG[:password] = val }

    op.on('-q', 'Disable logging') { PARAMS_CONFIG[:logging] = false }
    op.on('-v', 'Enable verbose output') { PARAMS_CONFIG[:logging] = !(PARAMS_CONFIG[:log_level] = :debug).nil? }
  end

  begin
    parser.parse!(ARGV.dup)
  rescue StandardError => e
    PARAMS_CONFIG[:optparse_error] = e
  end

  ActiveMatrix.debug! if ENV['MATRIX_DEBUG'] == '1'
end