Permalink
Browse files

Merge pull request #453 from kylethedude/master

Allow plugins to initialize at server startup
  • Loading branch information...
2 parents 2b313e4 + ab94c40 commit 67bafbc680646fc0cbe731b2d49ac6186438cdba @plamoni committed Feb 27, 2013
Showing with 15 additions and 1 deletion.
  1. +15 −1 lib/siriproxy/command_line.rb
@@ -9,6 +9,8 @@ class SiriProxy
end
class SiriProxy::CommandLine
+ $LOG_LEVEL = 0
+
BANNER = <<-EOS
Siri Proxy is a proxy server for Apple's Siri "assistant." The idea is to allow for the creation of custom handlers for different actions. This can allow developers to easily add functionality to Siri.
@@ -46,7 +48,8 @@ def initialize
def run_console
load_code
- $LOG_LEVEL = 0
+ init_plugins
+
# this is ugly, but works for now
SiriProxy::PluginManager.class_eval do
def respond(text, options={})
@@ -82,6 +85,7 @@ def run_bundle(subcommand='')
def run_server(subcommand='start')
load_code
+ init_plugins
start_server
# @todo: support for forking server into bg and start/stop/restart
# subcommand ||= 'start'
@@ -198,4 +202,14 @@ def load_code
require 'siriproxy/plugin'
require 'siriproxy/plugin_manager'
end
+
+ def init_plugins
+ pManager = SiriProxy::PluginManager.new
+ pManager.plugins.each_with_index do |plugin, i|
+ if plugin.respond_to?('plugin_init')
+ $APP_CONFIG.plugins[i]['init'] = plugin.plugin_init
+ end
+ end
+ pManager = nil
+ end
end

0 comments on commit 67bafbc

Please sign in to comment.