Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

45
LINES

< > BotCompany Repo | #1023440 // Discord Hopper Bot [eats Discord tokens & duplicates itself, seems to work]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 8300K of libraries. Click here for Pure Java version (11184L/80K).

!7

do not include function dm_current_generic.
do not include function dm_current_mandatory_generic.

module DiscordHopper > DynPrintLogAndEnabled {
  !include #1023434 // Discord
  bool discordEnabled() { ret enabled; }
  bool printToModule() { true; }
  
  start-thread {
    startDiscord();
    dm_vmBus_onMessage_q incomingDiscordMessage(voidfunc(Map map) {
      if (!enabled) ret;
      O module = map.get('module);
      if (!dm_isMe(module)) ret;
      S s = getString content(map);
      
      if (eq(s, "!bot count"))
        ret with dm_call(module, 'reply, map, lstr(dm_activeDiscordTokens()));

      LS tokens = extractPossibleDiscordTokens(s);
      for unnull (S token : tokens) {
        S answer = "That's a Discord token!";
        if (contains(concatLists((LLS) vmBus_queryAll activeDiscordTokens()), token))
          answer += " And I'm there already.";
        else {
          answer += " Jumping there!!";
          dm_showNewModuleWithParams(dm_moduleLibID(), discordToken := token);
        }
        dm_call(module, 'reply, map, answer);
      }
    });
  }
  
  // API
  
  S migrateToType(S moduleLibID) {
    S moduleID = assertNotNull(dm_showNewModuleWithParams(moduleLibID, +discordToken));
    print("Migrated to new module " + moduleID + ", disabling me");
    setEnabled(false);
    dm_reload(); // actually disable Discord
    ret moduleID;
  }
}

Author comment

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: 324 / 1096
Version history: 10 change(s)
Referenced in: [show references]