Libraryless. Click here for Pure Java version (6379L/45K/142K).
1 | !752 |
2 | |
3 | // Safe-for-everyone bots only!! |
4 | static L<S> okToForwardTo = litlist("OK Collector Bot", "Leo Bot", "Identity Manager", "Who Is Online Bot",
|
5 | "I'm Jack's Identity Manager"); |
6 | |
7 | // May include the privileged bots. |
8 | static Map<S, S> autoStartable = litmap( |
9 | "Who Is Online Bot", "#1001768", |
10 | "Reboot Bot", "#1001218", |
11 | "OK Collector Bot", "#1001245", |
12 | "Leo Bot", "#1001294", |
13 | "Identity Manager", "#1001348", |
14 | "I'm Jack's Identity Manager", "#1003170" |
15 | ); |
16 | |
17 | static S masterKey; |
18 | |
19 | p {
|
20 | masterKey = loadSnippet("#1006007");
|
21 | //readLocally("okToForwardTo");
|
22 | |
23 | Android3 a = new Android3("Public Comm Bot at " + getComputerID() + ".");
|
24 | a.publicOverride = true; |
25 | a.useMultiPort = false; |
26 | a.startPort = 4999; |
27 | makeAndroid(a); |
28 | } |
29 | |
30 | static synchronized S answer(S s) {
|
31 | new Matches m; |
32 | |
33 | if (match3("test", s))
|
34 | return "test!"; |
35 | |
36 | // TODO: include a timestamp :) |
37 | if (match3("signed *", s, m)) {
|
38 | S signed = m.unq(0); |
39 | isSignedWithKey_verbose = true; |
40 | if (!isSignedWithKey(signed, masterKey)) {
|
41 | print("masterKey: " + masterKey);
|
42 | ret "Sorry, bad signature."; |
43 | } |
44 | S line = unsign(signed); |
45 | S answer = answerPrivileged(line); |
46 | if (answer != null) ret answer; |
47 | } |
48 | |
49 | if (match3("please forward to bot *: *", s, m)) {
|
50 | S bot = unquote(m.m[0]); |
51 | S line = unquote(m.m[1]); |
52 | if (!okToForwardTo.contains(bot)) |
53 | return "Can't forward to this bot, sorry."; |
54 | if (!lineOK(bot, line)) |
55 | return "Can't forward that line, sorry."; |
56 | ret forwardTo(bot, line); |
57 | } |
58 | |
59 | return null; |
60 | } |
61 | |
62 | static S answerPrivileged(S s) {
|
63 | // privileged path after auth with master key - anything goes!! |
64 | |
65 | new Matches m; |
66 | |
67 | if (match3("please forward to bot *: *", s, m)) {
|
68 | S bot = unquote(m.m[0]); |
69 | S line = unquote(m.m[1]); |
70 | ret forwardTo(bot, line); |
71 | } |
72 | |
73 | if (match3("please start program *", s, m)) {
|
74 | S progID = m.unq(0); |
75 | nohupJavax(progID); |
76 | ret "OK."; |
77 | } |
78 | |
79 | if (match3("please restart program *", s, m)) {
|
80 | S progID = m.unq(0); |
81 | restartProgramID(progID); |
82 | ret "OK."; |
83 | } |
84 | |
85 | if (match3("please start bot *", s, m)) {
|
86 | S botID = m.unq(0); |
87 | startBot(botID); |
88 | ret "OK."; |
89 | } |
90 | |
91 | if (match3("please reboot", s)) {
|
92 | ret forwardTo("Reboot Bot", "Please reboot the machine.");
|
93 | } |
94 | |
95 | if (match3("list bots", s))
|
96 | ret structure(fullBotScan()); |
97 | |
98 | ret null; |
99 | } |
100 | |
101 | static boolean lineOK(S bot, S line) {
|
102 | return true; // OK Collector bot is not very dangerous... |
103 | } |
104 | |
105 | static S forwardTo(S bot, S line) {
|
106 | S id = autoStartable.get(bot); |
107 | if (id != null) |
108 | startBot(bot, id); |
109 | ret sendToLocalBotOpt(bot, line); |
110 | } |
Began life as a copy of #1001222
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1001248 |
| Snippet name: | Public Comm Bot with forwarding (LIVE) |
| Eternal ID of this version: | #1001248/1 |
| Text MD5: | 786f95d48977d7a199586156648f8122 |
| Transpilation MD5: | f51bf93da5c2a0ec4e798a46f9a4601f |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-12-14 03:24:53 |
| Source code size: | 2717 bytes / 110 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1150 / 1740 |
| Referenced in: | [show references] |