!7 cmodule Giraffe > DynDiscordHopper { switchable S myName = "Giraffe"; switchable S sliceID = "wgeuwbcepeoxfwma"; // "Height bot" slice - https://agi.blue/?slice=cxbfnllthxfsuwxw transient PKIKeyPair keys; start { keys = keyPairForProgram(); dm_vmBus_onMessage_q('discordGuildJoin, voidfunc(Map map) { ret unless map.get('module) == module(); postInChannel(preferredChannelID, questionToAsk()); }); } @Override S answer(S input, Map map) { ret mapEachLine_tlft_nempties(input, s -> { new Matches m; // preprocess if (discordBotID != 0) s = replacePrefix("<@" + discordBotID + ">", myName + " ", s); s = simpleSpaces_noTok(s); if "what's your name" ret myName; if (eqic(s, "hey " + myName)) ret or2(questionToAsk(), "I don't know what to ask"); if (swic_trim(s, myName + " example for: ", m)) ret findExample(m.rest()); null; }); } S questionToAsk() { ret (S) random(jsonDecodeList(agiBlue_query([[ question to ask / is / $x return $x ]], slice := sliceID))); } // assume s is sanitized S findExample(S s) { ret (S) random(jsonDecodeList(agiBlue_query([[ $x / isA / *** return $x ]].replace("***", s), slice := sliceID))); } }