diff options
author | M. Hecker <apoc@sixserv.org> | 2014-09-03 15:47:30 +0200 |
---|---|---|
committer | M. Hecker <apoc@sixserv.org> | 2014-09-03 15:47:30 +0200 |
commit | 53cfadbb9f2b25efe4c22b2fd02f8bc33b5e9d2d (patch) | |
tree | aba88155d1355723139b315b05e33eb49b732298 /lib/rbot | |
parent | 836cf49c210ebfeb443861d26379a81b333c2c78 (diff) |
[webservice] expose webservice to plugins
Diffstat (limited to 'lib/rbot')
-rw-r--r-- | lib/rbot/core/webservice.rb | 12 | ||||
-rw-r--r-- | lib/rbot/ircbot.rb | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/rbot/core/webservice.rb b/lib/rbot/core/webservice.rb index 21acf87d..26465285 100644 --- a/lib/rbot/core/webservice.rb +++ b/lib/rbot/core/webservice.rb @@ -69,7 +69,12 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet botuser = @bot.auth.get_botuser(username) raise 'Permission Denied' if not botuser or botuser.password != password - ret = dispatch_command(command, botuser, ip) + begin + ret = dispatch_command(command, botuser, ip) + rescue + debug '[webservice] error: ' + $!.to_s + debug $@.join("\n") + end res.status = 200 if req['Accept'] == 'application/json' @@ -119,6 +124,7 @@ class WebServiceModule < CoreBotModule @port = @bot.config['webservice.port'] @host = @bot.config['webservice.host'] @server = nil + @bot.webservice = self begin start_service if @bot.config['webservice.autostart'] rescue => e @@ -184,6 +190,10 @@ class WebServiceModule < CoreBotModule m.reply s end + def register_servlet(plugin, servlet) + @server.mount('/plugin/%s' % plugin.name, servlet, plugin, @bot) + end + end webservice = WebServiceModule.new diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index f74b1530..18b9e1d4 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -202,6 +202,8 @@ class Bot # loads and opens new registry databases, used by the plugins attr_accessor :registry_factory + attr_accessor :webservice + # server we are connected to # TODO multiserver def server |