Class: Server

Inherits:
EM::Connection
  • Object
show all
Includes:
EM::HttpServer
Defined in:
lib/cogbot/server.rb

Instance Method Summary collapse

Constructor Details

#initialize(bot) ⇒ Server



4
5
6
# File 'lib/cogbot/server.rb', line 4

def initialize(bot)
  @bot = bot
end

Instance Method Details

#post_initObject



8
9
10
11
# File 'lib/cogbot/server.rb', line 8

def post_init
  super
  no_environment_strings
end

#process_http_requestObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cogbot/server.rb', line 13

def process_http_request
  if @http_request_method == "POST"
    pluginlist = @bot.plugins.map { |e| e.class.name.split('::').last.downcase }
    query = @http_request_uri[1..-1]
    if pluginlist.include? query
      @bot.handlers.dispatch("http_#{query}".to_sym, nil, @http_post_content)
    end
  end

  response = EM::DelegatedHttpResponse.new(self)
  response.status = 200
  response.send_response
end