# Registers botmodule _botmodule_ with command _cmd_ and command path _auth_path_
def register(botmodule, cmd, auth_path)
- raise TypeError, "First argument #{botmodule.inspect} is not of class BotModule" unless botmodule.class <= BotModule
+ raise TypeError, "First argument #{botmodule.inspect} is not of class BotModule" unless botmodule.kind_of?(BotModule)
kl = botmodule.botmodule_class
@commandmappers[kl.to_sym][cmd.to_sym] = {:botmodule => botmodule, :auth => auth_path}
h = @commandmappers[kl.to_sym][cmd.to_sym]
end
def add_botmodule(botmodule)
- raise TypeError, "Argument #{botmodule.inspect} is not of class BotModule" unless botmodule.class <= BotModule
+ raise TypeError, "Argument #{botmodule.inspect} is not of class BotModule" unless botmodule.kind_of?(BotModule)
kl = botmodule.botmodule_class
raise "#{kl.to_s} #{botmodule.name} already registered!" if @botmodules[kl.to_sym].include?(botmodule)
@botmodules[kl.to_sym] << botmodule
# call the cleanup method for each active plugin
def cleanup
- @bot.save_mutex.synchronize do
- delegate 'cleanup'
- end
+ delegate 'cleanup'
reset_botmodule_lists
end
key = $1
params = $2
(core_modules + plugins).each { |p|
- # debug "checking #{p.name.inspect} against #{key.inspect}"
+ next unless p.name == key
begin
- return p.help(params)
+ return p.help(key, params)
rescue Exception => err
#rescue TimeoutError, StandardError, NameError, SyntaxError => err
error report_error("#{p.botmodule_class} #{p.name} help() failed:", err)
- end if p.name == key
+ end
}
+ k = key.to_sym
[core_commands, plugin_commands].each { |pl|
- # debug "looking for #{key.inspect} in #{pl.keys.sort.inspect}"
- if pl.has_key?(key)
- p = pl[key][:botmodule]
- begin
- return p.help(key, params)
- rescue Exception => err
- #rescue TimeoutError, StandardError, NameError, SyntaxError => err
- error report_error("#{p.botmodule_class} #{p.name} help() failed:", err)
- end
+ next unless pl.has_key?(k)
+ p = pl[k][:botmodule]
+ begin
+ return p.help(p.name, topic)
+ rescue Exception => err
+ #rescue TimeoutError, StandardError, NameError, SyntaxError => err
+ error report_error("#{p.botmodule_class} #{p.name} help() failed:", err)
end
}
end
# debug "#{p.botmodule_class} #{p.name} responds"
p.send method, *args
rescue Exception => err
- raise if err.class <= SystemExit
+ raise if err.kind_of?(SystemExit)
error report_error("#{p.botmodule_class} #{p.name} #{method}() failed:", err)
- raise if err.class <= BDB::Fatal
+ raise if err.kind_of?(BDB::Fatal)
end
end
}
# debug "#{p.botmodule_class} #{p.name} responds"
p.privmsg(m)
rescue Exception => err
- raise if err.class <= SystemExit
+ raise if err.kind_of?(SystemExit)
error report_error("#{p.botmodule_class} #{p.name} privmsg() failed:", err)
- raise if err.class <= BDB::Fatal
+ raise if err.kind_of?(BDB::Fatal)
end
# debug "Successfully delegated #{m.message}"
return true