!7 cmodule ChatBotFrontend > DynChatBotFrontend { Set scriptRefs = syncSet(); transient L scripts; start-thread { while (dm_booting()) sleepSeconds(0.1); loadScripts(); } void loadScripts { new L scripts; for (S ref : scriptRefs) pcall { LS l = splitAtSlash(ref); if (l(l) != 3) continue with print("Can't load script: " + ref); S mod = dm_require(first(l) + "/" + second(l)); Class c = dm_getClassInModuleRealm(mod, "main$" + last(l)); if (c == null) continue with print("Couldn't find class: " + ref); O o = nu(c); forwardSwappableFunctionsToObject(o, module(), 'setBotName, 'getBotName); scripts.add(o); print("Got script: " + o); } this.scripts = scripts; } @Override S answer_other(S s) null { fOr (virtual CruddieScript script : scripts) pcall { try S a = (S) call(script, 'answer, s); } } // API void addScript(S moduleLibID, S shortClassName) { if (scriptRefs.add(addPrefix("#", moduleLibID) + "/" + assertIdentifier(shortClassName))) { change(); loadScripts(); } } }