Module: Lobstersbot::SummerPatches

Defined in:
lib/lobstersbot/summer_patches.rb

Instance Method Summary collapse

Instance Method Details

#config_dir(file) ⇒ Object



5
6
7
# File 'lib/lobstersbot/summer_patches.rb', line 5

def config_dir(file)
  File.join(ARGV[0], file)
end

#connect!Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lobstersbot/summer_patches.rb', line 13

def connect!
  @connection = TCPSocket.open(server, port)

  if config[:use_ssl]
    cert_file = File.read(config_dir('client.pem'))
    context = OpenSSL::SSL::SSLContext.new
    context.key = OpenSSL::PKey.read(cert_file)
    context.cert = OpenSSL::X509::Certificate.new(cert_file)

    @connection = OpenSSL::SSL::SSLSocket.new(@connection, context).connect
  end

  response("USER #{config[:nick]} #{config[:nick]} #{config[:nick]} #{config[:nick]}")
  response("NICK #{config[:nick]}")
end

#load_configObject



9
10
11
# File 'lib/lobstersbot/summer_patches.rb', line 9

def load_config
  @config = HashWithIndifferentAccess.new(YAML.load_file(config_dir('lobstersbot.yml')))
end