Uses 8300K of libraries. Click here for Pure Java version (11184L/80K).
1 | !7 |
2 | |
3 | do not include function dm_current_generic. |
4 | do not include function dm_current_mandatory_generic. |
5 | |
6 | module DiscordHopper > DynPrintLogAndEnabled { |
7 | !include #1023434 // Discord |
8 | bool discordEnabled() { ret enabled; } |
9 | bool printToModule() { true; } |
10 | |
11 | start-thread { |
12 | startDiscord(); |
13 | dm_vmBus_onMessage_q incomingDiscordMessage(voidfunc(Map map) { |
14 | if (!enabled) ret; |
15 | O module = map.get('module); |
16 | if (!dm_isMe(module)) ret; |
17 | S s = getString content(map); |
18 | |
19 | if (eq(s, "!bot count")) |
20 | ret with dm_call(module, 'reply, map, lstr(dm_activeDiscordTokens())); |
21 | |
22 | LS tokens = extractPossibleDiscordTokens(s); |
23 | for unnull (S token : tokens) { |
24 | S answer = "That's a Discord token!"; |
25 | if (contains(concatLists((LLS) vmBus_queryAll activeDiscordTokens()), token)) |
26 | answer += " And I'm there already."; |
27 | else { |
28 | answer += " Jumping there!!"; |
29 | dm_showNewModuleWithParams(dm_moduleLibID(), discordToken := token); |
30 | } |
31 | dm_call(module, 'reply, map, answer); |
32 | } |
33 | }); |
34 | } |
35 | |
36 | // API |
37 | |
38 | S migrateToType(S moduleLibID) { |
39 | S moduleID = assertNotNull(dm_showNewModuleWithParams(moduleLibID, +discordToken)); |
40 | print("Migrated to new module " + moduleID + ", disabling me"); |
41 | setEnabled(false); |
42 | dm_reload(); // actually disable Discord |
43 | ret moduleID; |
44 | } |
45 | } |
Began life as a copy of #1023439
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1023440 |
Snippet name: | Discord Hopper Bot [eats Discord tokens & duplicates itself, seems to work] |
Eternal ID of this version: | #1023440/11 |
Text MD5: | fb7e5483ff591bf0ddb093917e8063cb |
Transpilation MD5: | 1c225fd278e5af9b0e90b19469e46628 |
Author: | stefan |
Category: | javax / discord / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-06-25 23:43:18 |
Source code size: | 1429 bytes / 45 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 326 / 1099 |
Version history: | 10 change(s) |
Referenced in: | [show references] |