!747 m { !include #1000850 // TableFinder static DialogIO cacheBot; static int linesSent; p { cacheBot = findMandatoryBot("Snippet Cache Bot"); for (Change c : getLatestChanges()) updateCache(c); print("Done, collecting responses from cache bot."); while (linesSent > 0) { --linesSent; cacheBot.waitForLine(); print("CacheBot says: " + cacheBot.readLineNoBlock()); } } static S sourceInfo() { return "meta " + quote(getProgramID() + "@" + getComputerID() + "@" + now()) + " - "; } static void toCacheBot(S s) { print("@Cache Bot: " + s); cacheBot.sendLine(s); ++linesSent; } static void updateCache(Change c) { toCacheBot(sourceInfo() + "Just got it from the web. Snippet " + quote(c.id) + " now has md5 " + quote(c.md5) + " and title " + quote(c.title) + "."); } static class Change { S id, title, md5; *(S *id, S *title, S *md5) {} *() {} } static L getLatestChanges() { S html = loadPage("http://tinybrain.de:8080/tb/snippets.php?withmd5=1"); new TableFinder finder; finder.go(html); new L changes; for (int i = 1; i < finder.data.size(); i++) { L row = finder.getRow(i); S title = dropAllTags(row.get(0)); S id = dropAllTags(row.get(1)); S md5 = dropAllTags(row.get(2)); changes.add(new Change(id, title, md5)); } return changes; } }