Warning: session_start(): open(/var/lib/php/sessions/sess_9v0tdlsefmuu434bgo2r73k3n2, 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
abstract sclass DynAttractorBot > DynPrintLog {
S input, dialogText;
bool voiceMode;
AttractorBot bot;
transient L onBotSaid = synchroList(); // L>
transient bool activateOnOutput = true;
bool persistBot;
void submitInput(S input) {
setField(+input);
submitInput();
}
void submitInput {
lock lock;
setField(input := trim(input));
addToDialog("User: " + input);
S s = input;
if "new dialogue|new dialog"
startDialog();
else if (bot != null)
bot.addInput(input);
}
visual jtabs("Dialog" :=
northCenterAndSouthWithMargins(
rightAlignedButtons(
dm_fieldCheckBox('voiceMode),
"New dialog", rThread startDialog,
"Clear window", rThread clearDialogText),
wordWrapTextArea(dm_textArea_scrollDown_readOnly('dialogText)),
dm_textFieldAndSubmit_q('input, 'submitInput, focusOnShow := true)), "Log" := super);
void runBot(AttractorBot bot) {
this.bot = bot;
runBot();
}
void addToDialog(S s) {
setField(dialogText := appendWithNewLine(dialogText, print(s)));
}
void runBot {
bot.say = voidfunc(S s) {
addToDialog("Bot: " + s);
pcallFAll(onBotSaid, s);
vmBus_send aBotSaid(me(), s);
if (voiceMode) {
if (activateOnOutput) dm_activateOSAndModule();
dm_say(s);
}
};
thread "Bot" {
bot.run_public();
print("\n[end]");
}
}
void clearDialogText {
setField(dialogText := "");
}
abstract AttractorBot makeBot();
void makeBotIfNotThere {
dm_runInQAndWait(r {
if (bot == null) bot = makeBot();
});
}
void startDialog {
clearDialogText();
makeBotIfNotThere();
runBot(bot);
}
start {
logModuleOutput();
dontPersist('bot);
dm_onTopInput_q(voidfunc(S s) {
if (!voiceMode) ret;
//dm_activateOSAndModule();
submitInput(s);
});
startDialog();
}
}