!7 !include once #1026298 // use JDA 4.0 standardBot1 TomiiBoiDiscordBot { S dbBotID = #1026409; init { if (myName == null) setField(myName := "Tomii"); preprocessAtSelfToMyName = true; escapeAtEveryone = true; } sync S processSimplifiedLine(S s, O... _) { try answer super.processSimplifiedLine(s, _); new Matches m; if (swic_trim(s, "gbot:", m)) ret gbot(m.rest(), paramsToMap(map)); O dbBot = eleu_getBot(dbBotID); if (dbBot == null) ret null with print("No DB bot found (" + dbBotID + ")"); temp tempSetTL((ThreadLocal) getOpt(dbBot, 'opt_noDefault), true); try answer (S) call(dbBot, 'answer, s, "en"); } S gbot(S query, Map map, O... _) { LS l = regexpICFullMatch_groups("(\\d+) results? for[ :](.+)", query); int results = defaultResults; if (l != null) { results = parseInt(first(l)); query = unquote(trim(last(l))); } bool safeSearch = !discord_isNSFWChannel_gen(map.get('channel)); module().setField(searches := searches+1); updateModuleName(); ret discord_google(query, paramsPlus(_, +results, +safeSearch)); } }