1 | static Map<S, Status> status_map; // key = dialog id |
2 | |
3 | static abstract class Status { |
4 | abstract S answer(S s); |
5 | } |
6 | |
7 | // get status |
8 | static synchronized Status status() { |
9 | status_load(); |
10 | ret status_map.get(getDialogID()); |
11 | } |
12 | |
13 | static void status_load() { |
14 | if (status_map == null) { |
15 | status_map = new TreeMap; |
16 | load("status_map"); |
17 | } |
18 | } |
19 | |
20 | // set status |
21 | static synchronized void status(Status s) { |
22 | status_load(); |
23 | if (s == null) |
24 | status_map.remove(getDialogID()); |
25 | else |
26 | status_map.put(getDialogID(), s); |
27 | save("status_map"); |
28 | } |
29 | |
30 | static S status_answer(S s) { |
31 | Status status = status(); |
32 | if (status != null) |
33 | ret status.answer(s); |
34 | ret null; |
35 | } |
Began life as a copy of #1002567
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: | #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: | 818 / 755 |
Referenced in: | [show references] |