static class ChatLine { int id, room; S who, text; boolean isBot, auth; } static int suckWebChat_lastID; static long suckWebChat_lastSuck; static int suckWebChat_room = 1; static L suckWebChat(S myName) { ret suckWebChat(myName, 1); } // suckFirst = how many lines to suck on startup (history) static L suckWebChat(S myName, int suckFirst) { if (now() < suckWebChat_lastSuck + 500) print("Warning: Sucking a lot :)"); suckWebChat_lastSuck = now(); int n = suckWebChat_lastID == 0 ? suckFirst : 1000; Map data = (Map) jsonDecode(loadPageSilently("tinybrain.de:8080/tb-int/groupchat.json.lines.php?room=" + suckWebChat_room + "&fromID=" + suckWebChat_lastID + "&n=" + n + "&who=" + urlencode(myName))); L> lines = (L) data.get("lines"); new L list; for (Map m : lines) { new ChatLine l; l.who = m.get("who"); l.text = m.get("text"); l.isBot = "1".equals(m.get("bot")); l.auth = eq(m.get("auth"), "1"); l.id = parseInt(m.get("id")); l.room = room; if (l.id > suckWebChat_lastID) suckWebChat_lastID = l.id; list.add(l); } ret list; }