Download Jar. Libraryless. Click here for Pure Java version (5817L/40K).
1 | !7 |
2 | |
3 | sS regexpActivator = "."; // always |
4 | |
5 | !include once #1017764 // VirtualMechLists |
6 | |
7 | sS mechLibID = #1400124; |
8 | static O onOutput; // VF1<S> |
9 | static bool authorized; |
10 | sS msgGlobalID; |
11 | |
12 | static L<AbstractThinkBot> bots; |
13 | |
14 | abstract sclass AbstractThinkBot { |
15 | transient VF1<? super S> postMessage; |
16 | transient new L<Map> recentHistory; |
17 | |
18 | abstract void thinkAbout(S input); |
19 | |
20 | void postMessage(S s) { |
21 | callF(postMessage, s); |
22 | } |
23 | |
24 | JComponent visualize() { |
25 | ret jpanel(); |
26 | } |
27 | } |
28 | |
29 | p { |
30 | mech_useLibrary(mechLibID); |
31 | L<Class<? extends AbstractThinkBot>> classes = botClasses(); |
32 | print("Have think classes: " + classNames(classes)); |
33 | makeBots(); |
34 | bot(); |
35 | } |
36 | |
37 | static L<Class<? extends AbstractThinkBot>> botClasses() { |
38 | ret myNonAbstractClassesImplementing(AbstractThinkBot); |
39 | } |
40 | |
41 | svoid makeBots() { |
42 | bots = map nuWithoutArguments(botClasses()); |
43 | } |
44 | |
45 | sbool telegram_amIAuthorized() { |
46 | ret authorized; |
47 | } |
48 | |
49 | svoid setMsgGlobalID(S globalID) { |
50 | msgGlobalID = globalID; |
51 | } |
52 | |
53 | sS answer(S s) { |
54 | temp tempSetThreadLocal(telegram_msg_tl(), litorderedmap(globalID := msgGlobalID)); |
55 | msgGlobalID = null; |
56 | final new L<S> output; |
57 | for (AbstractThinkBot bot : bots) pcall { |
58 | bot.postMessage = voidfunc(S s) { |
59 | print(">> " + s); |
60 | pcallF(onOutput, s); |
61 | output.add(s); |
62 | }; |
63 | bot.thinkAbout(s); |
64 | } |
65 | ret rtrim(lines(output)); |
66 | } |
67 | |
68 | svoid setDebug(bool b) { |
69 | for (O bot : unnull(bots)) |
70 | setOpt(bot, debug := b); |
71 | } |
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017703 |
Snippet name: | Baked Bot Main Program (assembled into #1017706) |
Eternal ID of this version: | #1017703/30 |
Text MD5: | f710d5889df7044abe2f1728f139a87e |
Transpilation MD5: | 3e3c7d67e1ebd370ebf953d7b2d93744 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-08-18 15:50:55 |
Source code size: | 1488 bytes / 71 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 680 / 1665 |
Version history: | 29 change(s) |
Referenced in: | [show references] |