!7 concept CLotteryResult { S date; L numbers; S jackpot; [stdToString] } standardBot1 LotteryBot { init { dbIndexing(CLotteryResult, 'date); doEveryHourAndNow(r grabResults); } allServers { S lotteryURL = "https://www.lotteryusa.com/missouri/show-me-cash/"; void grabResults enter { LotteryResult r = scrapeLotteryResults(loadPage(lotteryURL)); if (r == null) ret with print("No lottery results!?"); CLotteryResult lr = uniq(CLotteryResult, date := r.date); copyFields(r, lr); print("Grabbed: " + lr); } S renderResult(CLotteryResult r) { ret formatCSVLine(r.date, joinWithComma(r.numbers), r.jackpot); } } processSimplified { s = dropMyPrefixOpt(s); if "lottery|lottery results|show me cash" { optPar long channelID; L l = sortedByFieldDesc date(list(CLotteryResult)); if (empty(l)) ret "No lottery results gathered yet"; S date1 = first(l).date; S text = mapToLines_rtrim(l, lambda1 renderResult); uploadFileInChannel(channelID, toUtf8(text), "lottery-" + date1 + ".txt", null, null); null; } } }