]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blob - data/rbot/plugins/httpd.rb
92fe3a80969eb6371f0bb14f3b6f35ab2a320ff8
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / httpd.rb
1 require 'webrick'
2
3 class HttpPlugin < Plugin
4   include WEBrick
5
6
7   def initialize
8     super
9     @http_server = HTTPServer.new(
10       :Port => 5555
11     )
12     @http_server.mount_proc("/") { |req, resp|
13       resp['content-type'] = 'text/html'
14       resp.body = "<html><head><title>rbot httpd plugin</title></head><body>"
15       resp.body += "#{@bot.status} <br />"
16       resp.body += "hello from rbot."
17       resp.body += "</body>"
18       raise HTTPStatus::OK
19     }
20     Thread.new {
21       @http_server.start
22     }
23   end
24   def cleanup
25     @http_server.shutdown
26   end
27   def help(plugin, topic="")
28     "no help yet"
29   end
30   def privmsg(m)
31   end
32 end
33
34 plugin = HttpPlugin.new
35 plugin.register("http")