// TODO: wait for chat to come up
static void simpleChatListen() {
O chat = simpleChatBot();
if (chat == null)
simpleChatListen_remote();
else {
simpleChatListen_n = (int) call(chat, "size");
simpleChatNotifyMe();
}
}
static void simpleChatListen_remote() {
thread "Chat Listener" {
simpleChatListen_n = parseInt(loadPage("http://ai1.lol/" + simpleChatID() + "/raw/n"));
while (licensed()) {
pcall {
L msgs = cast unstructure(htmldecode(loadPage("http://ai1.lol/" + simpleChatID() + "/raw/incremental?robo=1&a=" + simpleChatListen_n)));
simpleChatListen_n += l(msgs);
process(msgs);
}
sleep(simpleChatListen_delay);
}
}
}
static volatile int simpleChatListen_delay = 5000;
static int simpleChatListen_n;
static void simpleChatUpdated() {
O chat = simpleChatBot();
int n2 = (int) call(chat, "size");
if (n2 > simpleChatListen_n) {
L msgs = cast call(chat, "getMessages", simpleChatListen_n, n2);
simpleChatListen_n = n2;
process(msgs);
}
}
Note: It keeps the program alive in the remote case (runs a listener thread)
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1003117 |
| Snippet name: | simpleChatListen - calls "process(L msgs)" method |
| Eternal ID of this version: | #1003117/1 |
| Text MD5: | 684a7d5f743d69dadbb124fe09450520 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-06-06 00:53:00 |
| Source code size: | 1083 bytes / 38 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1121 / 1095 |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |