!7 module OSChatBot > DynModule { transient S imageID = #1101205; transient JTextField tfInput; start { for (S s : lastNLinesOfFile(osChatBotLogFile(), 5)) pcall { if (isQuoted(s)) printLogEntry((L) unstruct(afterSpace(s))); } if (empty(osChatBotLogFile())) say("Hello!"); } visualize { onEnter(tfInput = jCenteredTextField(), r { S s = getText(tfInput); logStructureWithDate(osChatBotLogFile(), printLogEntry(ll("typed", s))); dm_setAIBarTextAndFire(s) }); ret withBottomMargin(20, centerAndSouthWithMargins( westAndCenterWithMargin(jimage(imageID), dm_printLogComponent()), jvstackWithSpacing( setFontSize(20, jCenteredBoldLabel("Hello!")), setFontSize(16, tfInput))); } void say(S s) { logStructureWithDate(osChatBotLogFile(), printLogEntry(ll("said", s))); } L printLogEntry(L l) { if (eq(first(l), "said")) print("Me: " + second(l)); else if (eq(first(l), "typed")) print("You: " + second(l)); ret l; } }