From 00c5060554ca2546e3462f69a27fca521c0889aa Mon Sep 17 00:00:00 2001 From: Dmitry Kim Date: Thu, 10 May 2007 23:03:19 +0000 Subject: [PATCH] + (plugins) draft implementation of event hooks --- lib/rbot/plugins.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb index 7b476da9..ab7be40a 100644 --- a/lib/rbot/plugins.rb +++ b/lib/rbot/plugins.rb @@ -141,6 +141,10 @@ module Plugins @handler.handle(m) end + def call_event(ev, *args) + @bot.plugins.delegate('event_' + ev.to_s.gsub(/[^\w\?!]+/, '_'), *args) + end + def map(*args) @handler.map(self, *args) # register this map @@ -578,12 +582,13 @@ module Plugins # +message+ as a parameter def delegate(method, *args) # debug "Delegating #{method.inspect}" + ret = Array.new [core_modules, plugins].each { |pl| pl.each {|p| if(p.respond_to? method) begin # debug "#{p.botmodule_class} #{p.name} responds" - p.send method, *args + ret.push p.send(method, *args) rescue Exception => err raise if err.kind_of?(SystemExit) error report_error("#{p.botmodule_class} #{p.name} #{method}() failed:", err) @@ -592,6 +597,7 @@ module Plugins end } } + return ret # debug "Finished delegating #{method.inspect}" end -- 2.39.5