!7 !include #1007827 // Slack Bot sbool doSlack = true; !include #1008066 // SelectBot with guess_match extend SelectBot { S name; } static SelectBot greetBot, timeBot, randomIDBot; p { // DB start & migration bootstrapConceptsFrom(#1007829); db(); if (countConcepts(SelectBot) == 1) cset(uniq(SelectBot), name := "greet"); greetBot = uniq(SelectBot, name := "greet"); timeBot = uniq(SelectBot, name := "time"); randomIDBot = uniq(SelectBot, name := "random"); slackSpeed = 1000; if (doSlack) initSlackBot(); dediSay("Back online!"); if (doSlack) slackBotLoop(); } static SelectBot getBot(S name) { ret findConcept(SelectBot, +name); } 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 if (startsWithWord(s, "!greet", m)) { greetBot.put($1, true); ret "ok"; } if (startsWithWord(s, "!nogreet", m)) { greetBot.put($1, false); ret "ok"; } if (startsWithWord(s, "!time", m)) { timeBot.put($1, true); ret "ok"; } if (startsWithWord(s, "!notime", m)) { timeBot.put($1, false); ret "ok"; } if (startsWithWord(s, "!random", m)) { randomIDBot.put($1, true); ret "ok"; } if (startsWithWord(s, "!random", m)) { randomIDBot.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(); if (eq(s, "!debug")) ret greetBot.lastMatch; // match on bots if (isTrue(greetBot.get(s))) ret s + " => hi!"; if (isTrue(timeBot.get(s))) ret s + " => It is " + hmsWithColons(); if (isTrue(randomIDBot.get(s))) ret s + " => " + aGlobalID(); }