]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
starting on an http interface for configuring the bot
authorTom Gilbert <tom@linuxbrit.co.uk>
Sun, 17 Jul 2005 22:56:16 +0000 (22:56 +0000)
committerTom Gilbert <tom@linuxbrit.co.uk>
Sun, 17 Jul 2005 22:56:16 +0000 (22:56 +0000)
rbot/plugins/httpd.rb [new file with mode: 0644]

diff --git a/rbot/plugins/httpd.rb b/rbot/plugins/httpd.rb
new file mode 100644 (file)
index 0000000..92fe3a8
--- /dev/null
@@ -0,0 +1,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")