Class: Irc::Utils::AgentFactory

Inherits:
Object
  • Object
show all
Defined in:
/home/apoc/projects/ruby/rbot/lib/rbot/core/utils/agent.rb

Instance Method Summary (collapse)

Constructor Details

- (AgentFactory) initialize(bot)

Returns a new instance of AgentFactory



47
48
49
# File '/home/apoc/projects/ruby/rbot/lib/rbot/core/utils/agent.rb', line 47

def initialize(bot)
  @bot = bot
end

Instance Method Details

- (Object) cleanup



51
52
# File '/home/apoc/projects/ruby/rbot/lib/rbot/core/utils/agent.rb', line 51

def cleanup
end

- (Object) create

Returns a new, unique instance of Mechanize.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File '/home/apoc/projects/ruby/rbot/lib/rbot/core/utils/agent.rb', line 55

def create
  agent = Mechanize.new
  agent.redirection_limit = @bot.config['agent.max_redir']
  if not @bot.config['agent.ssl_verify']
    agent.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  end
  if @bot.config['agent.proxy_use']
    agent.set_proxy(
      @bot.config['agent.proxy_host'],
      @bot.config['agent.proxy_port'],
      @bot.config['agent.proxy_username'],
      @bot.config['agent.proxy_password']
    )
  end
  agent
end