abstract sclass DynTalkBot > DynDiscordHopper { switchable S myName = "Anonymous bot"; transient bool useAGIBlueForDropPunctuation = true; L authorizedUsers = ll(463778175432785932, 545983823997960193); start { dm_vmBus_onMessage_q('discordGuildJoin, voidfunc(Map map) { ret unless map.get('module) == module(); print("Got join"); onUserJoin(getLong userID(map), map); }); } // overridable void onUserJoin(long userID, O... _) {} @Override S answer(S input, Map map) { ret mapEachLine_tlft_nempties(input, s -> { ret processLine(s, map); }); } S processLine(S s, O... _) { s = preprocess(s, _); ret processSimplifiedLine(s, _); } S preprocess(S s, O... _) { if (discordBotID != 0) s = replace(s, atSelf(), " " + myName + " "); s = dropPunctuation3_withAGIBlue(useAGIBlueForDropPunctuation, s); s = trim(simpleSpaces_noTok(s)); print("simplified >> " + quote(s)); ret s; } // extend me S processSimplifiedLine(S input, O... _) { new Matches m; if (swic_trim(input, atSelf() + " add master ", m)) { if (!contains(authorizedUsers, optPar userID(_))) ret "You are not my master"; add(authorizedUsers, parseFirstLong(m.rest())); change(); ret "Okidoki. Have " + n2(l(authorizedUsers), "master"); } null; } bool authed(O... _) { ret contains(authorizedUsers, optPar userID(_)); } }