Download Jar. Libraryless. Click here for Pure Java version (19755L/154K).
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 | } |
72 | |
73 | |
74 | |
75 | please include function dm_reloadMe. |
76 | |
77 | sclass TelegramFactsBot > AbstractThinkBot { |
78 | !include #1018379 |
79 | |
80 | visualize { |
81 | ret withCenteredButtons(super.visualize(), |
82 | "Checking Log", r { showText("Checking Log", lines(checkingLog)) }); |
83 | } |
84 | } |
Began life as a copy of #1017706
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018381 |
Snippet name: | Baked Bot, new version (auto-generated, don't edit, see #1017703) |
Eternal ID of this version: | #1018381/3 |
Text MD5: | a986685e806c4d358639d343aca9bfd8 |
Transpilation MD5: | 35d4577b066895a4b0c957b228411300 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-09-23 17:08:00 |
Source code size: | 1752 bytes / 84 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 379 / 1405 |
Version history: | 2 change(s) |
Referenced in: | [show references] |