diff options
-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 |