Libraryless. Click here for Pure Java version (9310L/60K).
1 | svoid philosophyBot1_addEnableableExtension(PhilosophyBot1 bot, S name, IVF1<PhilosophyBot1> enable) {
|
2 | Map<S, IVF1<PhilosophyBot1>> map = cast bot.getExtension("enableableExtensions");
|
3 | if (map == null) {
|
4 | // first time, register ourselves as an extension |
5 | bot.addExtension("enableableExtensions", map = new Map);
|
6 | Map<S, IVF1<PhilosophyBot1>> _map = map; |
7 | bot.addFactPreprocessor(s -> {
|
8 | new Matches m; |
9 | if "enable extension *" {
|
10 | IVF1<PhilosophyBot1> action = _map.get($1); |
11 | if (action == null) warn("Extension " + $1 + " not found");
|
12 | else action.get(bot); |
13 | true; |
14 | } |
15 | false; |
16 | }); |
17 | } |
18 | // after that, just add new entry to map |
19 | map.put(name, enable); |
20 | } |
Began life as a copy of #1027180
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1027309 |
| Snippet name: | philosophyBot1_addEnableableExtension |
| Eternal ID of this version: | #1027309/7 |
| Text MD5: | 16f18694598efdcfc48f130303802744 |
| Transpilation MD5: | 7076415ef985f552322b31b58750a591 |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-03-02 14:53:12 |
| Source code size: | 741 bytes / 20 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 376 / 524 |
| Version history: | 6 change(s) |
| Referenced in: | [show references] |