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

20
LINES

< > BotCompany Repo | #1017618 // listenForAppendsToRemoteMechList

JavaX fragment (include)

// > 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\"}"}

static WebSocketClient listenForAppendsToRemoteMechList(S listName, final VF1<S> onAppend) {
  final long listID = getRemoteMechListID(listName);
  if (listID == 0) ret null with print("List not found: " + listName);
  
  final LineBuffer buf = new(voidfunc(S s) {
    pcall {
      Map map = safeUnstructMap(s);
      if (eqGet(map, 'mode, "bot append") && eqGet(map, 'id, listID))
        callF(onAppend, getString(map, 'text));
    }
  });
  
  ret webSocketOnMessage_withIdler(webSocketButterBot(#1015684), voidfunc(S s) {
    new Matches m;
    if (startsWith(s, "+", m))
      buf.append(m.rest());
  }, 10.0, "look back 0 chars pw *", muricaPassword());
}

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: 213 / 239
Version history: 6 change(s)
Referenced in: [show references]