Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

20
LINES

< > BotCompany Repo | #1017618 // listenForAppendsToRemoteMechList

JavaX fragment (include)

1  
// > hm{"date"=1532956452412L, "mode"="bot append", "id"=392L, "text"="lhm{\"where\"=-1001255041751L, \"type\"=\"heard\", \"date\"=\"2018/07/30 15:14:44'0372\", \"originalDate\"=1532956483, \"text\"=\"are you nasty\", \"userID\"=604039341, \"userFirstName\"=\"Stefan\", \"userLastName\"=\"Reich\"}\nlhm{\"action\"=\"send\", \"text\"=\"Certainly not as nasty as you.\", \"date\"=\"2018/07/30 15:14:44'0948\", \"type\"=\"sent\"}"}
2  
3  
static WebSocketClient listenForAppendsToRemoteMechList(S listName, final VF1<S> onAppend) {
4  
  final long listID = getRemoteMechListID(listName);
5  
  if (listID == 0) ret null with print("List not found: " + listName);
6  
  
7  
  final LineBuffer buf = new(voidfunc(S s) {
8  
    pcall {
9  
      Map map = safeUnstructMap(s);
10  
      if (eqGet(map, 'mode, "bot append") && eqGet(map, 'id, listID))
11  
        callF(onAppend, getString(map, 'text));
12  
    }
13  
  });
14  
  
15  
  ret webSocketOnMessage_withIdler(webSocketButterBot(#1015684), voidfunc(S s) {
16  
    new Matches m;
17  
    if (startsWith(s, "+", m))
18  
      buf.append(m.rest());
19  
  }, 10.0, "look back 0 chars pw *", muricaPassword());
20  
}

Author comment

Began life as a copy of #1015686

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1017618
Snippet name: listenForAppendsToRemoteMechList
Eternal ID of this version: #1017618/7
Text MD5: cb17c3c9691f8f34bc54abad1fbd88eb
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-30 15:26:32
Source code size: 1111 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 215 / 242
Version history: 6 change(s)
Referenced in: [show references]