!7 !include #1007827 // Slack Bot sbool doSlack = true; !include #1008066 // SelectBot with guess_match static Set botNames = asSet(splitAtSpace("time greet random")); extend SelectBot { S name; } p { // DB start & migration bootstrapConceptsFrom(#1007829); db(); if (countConcepts(SelectBot) == 1) cset(uniq(SelectBot), name := "greet"); slackSpeed = 1000; if (doSlack) initSlackBot(); dediSay("Back online!"); if (doSlack) slackBotLoop(); } answer { s = trim(s); if (startsWith(s, "!data:", m)) ret struct(getBot($1)); if (startsWith(s, "!plus:", m)) ret struct(keysWithValue(getBot($1).examples, true)); if (startsWith(s, "!minus:", m)) ret struct(keysWithValue(getBot($1).examples, false)); // Train bots for (S bot : botNames) { if (startsWithWord(s, "!" + bot, m)) { getBot(bot).put($1, true); ret "ok"; } if (startsWithWord(s, "!no" + bot, m)) { getBot(bot).put($1, false); ret "ok"; } } // general if (eq(s, "!reload")) { actionsAfterPost.add(f restart); ret "krasser reload"; } if (eq(s, "!source")) ret progLink(); if (eq(s, "!help")) ret botAutoHelp(); // match on bots if (isTrue(getBot("greet").get(s))) ret s + " => hi!"; if (isTrue(getBot("time").get(s))) ret s + " => It is " + hmsWithColons(); if (isTrue(getBot("random").get(s))) ret s + " => " + aGlobalID(); } static SelectBot getBot(S name) { ret uniq(SelectBot, +name); } static L botAutoHelp_commands() { L cmds = _botAutoHelp_commands(); for (S bot : botNames) addAll(cmds, "!" + bot, "!no" + bot); ret cmds; }