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

35
LINES

< > BotCompany Repo | #1002616 - status function - per-user status for Eleutheria bots

JavaX fragment (include)

static Map<S, Status> status_map; // key = dialog id

static abstract class Status {
  abstract S answer(S s);
}

// get status
static synchronized Status status() {
  status_load();
  ret status_map.get(getDialogID());
}

static void status_load() {
  if (status_map == null) {
    status_map = new TreeMap;
    load("status_map");
  }
}

// set status
static synchronized void status(Status s) {
  status_load();
  if (s == null)
    status_map.remove(getDialogID());
  else
    status_map.put(getDialogID(), s);
  save("status_map");
}

static S status_answer(S s) {
  Status status = status();
  if (status != null)
    ret status.answer(s);
  ret null;
}

Author comment

Began life as a copy of #1002567

download  show line numbers  debug dex   

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

No comments. add comment

Snippet ID: #1002616
Snippet name: status function - per-user status for Eleutheria bots
Eternal ID of this version: #1002616/1
Text MD5: c6e9fa2f969ebd50fdd1491ef643e1c2
Author: stefan
Category: eleu
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-02-05 20:57:40
Source code size: 695 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 494 / 426
Referenced in: [show references]

Formerly at http://tinybrain.de/1002616 & http://1002616.tinybrain.de