コード例 #1
0
ファイル: FunctionScope.java プロジェクト: javawizard/jzbot
 private static Function getFunctionFromStorageContainer(
     FunctionScope scope, StorageContainer container, String name) {
   if (container == null) return null;
   StoredFunction f = container.getStoredFunction(name);
   if (f == null) return null;
   // Only include the version if we're a global function to disallow server-specific and
   // channel-specific
   // functions from accessing vaults. I'm sure there's a better way to do this, but this'll do for
   // now.
   // (Rationale being that someone could shadow a global function with a somewhat more nefarious
   // channel function
   // and go on the probability that the person maintaining the vault used by the global function
   // won't notice
   // that, at a particular channel, all of their precious code will be shadowed by code someone
   // else wrote.
   // There really ought to be a better way to do this, though - perhaps force global function
   // calls to always
   // run against other global functions, and require a specific function to be used to invoke
   // something at a
   // different scope? That's probably a better long-term solution. TODO: Do that)
   // Also, TODO: Include something in the name indicating the StorageContainer we located this at
   return new DynamicFunction(
       name,
       scope == GLOBAL ? f.getVersionNumber() : null,
       FactParser.parse(f.getValue(), "{" + name + "}"));
 }
コード例 #2
0
ファイル: FunctionScope.java プロジェクト: javawizard/jzbot
 @Override
 public String[] listFunctionNames(FactContext context, String prefix) {
   return Stream.of(FactParser.getFunctionNames())
       .filter((name) -> prefix == null || name.startsWith(prefix))
       .toArray((size) -> new String[size]);
 }
コード例 #3
0
ファイル: FunctionScope.java プロジェクト: javawizard/jzbot
 @Override
 public Function getFunction(FactContext context, String name) {
   return FactParser.getFunction(name);
 }