Warning: session_start(): open(/var/lib/php/sessions/sess_r3u1fhbec4lij5utrbq17p0ks4, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
concept Cmd {
S patterns; // for mmo_parsePattern
S cmd; // a pattern recognized by #1027443
int index;
transient MMOPattern parsedPattern;
void change { parsedPattern = null; super.change(); }
MMOPattern parsedPattern() {
if (parsedPattern == null) parsedPattern = mmo_parsePattern(patterns);
ret parsedPattern;
}
sS _fieldOrder = "patterns cmd index";
}
cmodule ScenariosFrontend > DynCRUD {
S backendModuleLibID = "#1027443/Scenarios";
transient Map argumentsForCommands = litcimap(
"new scenario *", ll("What is the name of the new scenario?"),
"delete scenario *", ll("Which scenario would you like to delete?"),
"rename scenario * to *", ll(
"Which scenario would you like to rename?",
"What is the new name for the scenario?")
);
S handleCommand(Cmd cmd) {
if (cmd == null) null;
print("handleCommand " + cmd.cmd);
if (hasAsteriskTokens(cmd.cmd))
{
LS argQuestions = argumentsForCommands.get(cmd.cmd);
try answer first(argQuestions);
ret "Need arguments";
// error fallback
} else
ret (S) dm_call(getBackend(), 'answer, cmd.cmd);
}
S getBackend() {
ret dm_require(backendModuleLibID);
}
afterVisualize {
addComponent(crud.buttons, jbutton("Talk to me", rThread talkToMe));
}
void talkToMe enter { dm_showConversationPopupForModule(); }
// API
void copyCommandsFromBackend() {
for (S cmd : allIfQuotedPatterns(loadSnippet(#1027443)))
uniqConcept(+cmd);
}
S answer(S s) {
ret handleCommand(mmo_matchMultiWithTypos(1,
filter(conceptsSortedByField Cmd('index), c -> nempty(c.patterns)),
c -> c.parsedPattern(), s));
}
}