summaryrefslogtreecommitdiff
path: root/lib/rbot/plugins/httpd.rb
blob: 92fe3a80969eb6371f0bb14f3b6f35ab2a320ff8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'webrick'

class HttpPlugin < Plugin
  include WEBrick


  def initialize
    super
    @http_server = HTTPServer.new(
      :Port => 5555
    )
    @http_server.mount_proc("/") { |req, resp|
      resp['content-type'] = 'text/html'
      resp.body = "<html><head><title>rbot httpd plugin</title></head><body>"
      resp.body += "#{@bot.status} <br />"
      resp.body += "hello from rbot."
      resp.body += "</body>"
      raise HTTPStatus::OK
    }
    Thread.new {
      @http_server.start
    }
  end
  def cleanup
    @http_server.shutdown
  end
  def help(plugin, topic="")
    "no help yet"
  end
  def privmsg(m)
  end
end

plugin = HttpPlugin.new
plugin.register("http")