Libraryless. Click here for Pure Java version (4054L/27K).
sclass CruddieFollower { S cookie; int n; double timeout = 70; swappable void newDialog() {} swappable void botUtterance(S html) { print("Bot said (HTML): " + html); vmBus_send cruddieSaid(cookie, html); } swappable void onUserUtterance(S html) {} // TODO swappable void onBotUtterance(S html) {} *(S cookie) { this(cookie, false); } *(S *cookie, bool withHistory) { if (!withHistory) n = parseInt(loadPageWithParamsSilently("https://cruddie.site/bot/n", +cookie); } // may block for 60 seconds. returns HTML public S get() { // TODO: I think cruddie.site doesn't close existing connections when rebooting (?) S src = loadPageWithTimeoutAndParamsSilently(timeout, "https://cruddie.site/bot/incremental", +cookie, a := zeroToNull(n)); S newN = firstIntAsString_regexp(src); if (nempty(newN)) { n = parseInt(newN); if (cic(src, "NEW DIALOG -->")) newDialog(); else doForEach botUtterance(regexpAllFirstGroups( [[bot-utterance">(.*?)<]], src)); } ret src; } }
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027721 |
Snippet name: | CruddieFollower - web client for cruddie |
Eternal ID of this version: | #1027721/22 |
Text MD5: | 1889aef814a05c031103e2a266ecb3d6 |
Transpilation MD5: | e1746412c7cfb6fa656cec0418445520 |
Author: | stefan |
Category: | javax / cruddie |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-04-20 23:12:03 |
Source code size: | 1113 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 249 / 646 |
Version history: | 21 change(s) |
Referenced in: | #1030351 - GazelleTalkToBot - web client for a Gazelle.rocks bot #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |