!7 !include #1007827 // Slack Bot sbool doSlack = true; extend SelectBot { S name; } static SelectBot greetBot, timeBot; 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"); slackSpeed = 1000; if (doSlack) initSlackBot(); dediSay("Back online!"); if (doSlack) slackBotLoop(); } answer { s = trim(s); if (eq(s, "!data:greet")) ret struct(greetBot); if (eq(s, "!plus:greet")) ret struct(keysWithValue(greetBot.examples, true)); if (eq(s, "!minus:greet")) ret struct(keysWithValue(greetBot.examples, false)); if (eq(s, "!data:time")) ret struct(timeBot); 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"; } // 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(); }