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

63
LINES

< > BotCompany Repo | #1001337 // Bot Receiving Bot

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (2344L/16K/53K).

!747

m {
  p {
    makeAndroid3("Bot receiving bot.");
  }
  
  static synchronized S answer(S s, L<S> history) {
    new Matches m;
    
    if (match3("please start bot * with data *.", s, m)) {
      S botID = formatSnippetID(unquote(m.m[0]));
      S dataID = formatSnippetID(unquote(m.m[1]));
      return doIt(botID, dataID);
    }
      
    if (match3("please start bot * with no data.", s, m)) {
      S botID = formatSnippetID(unquote(m.m[0]));
      return doIt(botID, null);
    }
      
    if (match3("please start bot from data *.", s, m)) {
      S dataID = formatSnippetID(unquote(m.m[0]));
      S title = getSnippetTitle(dataID);
      if (!find3("zip of #*", title, m))
        fail("Bot ID not found in title: " + quote(title));
      S botID = formatSnippetID(unquote(m.m[0]));
      return doIt(botID, dataID);
    }
      
    return null;
  }
  
  static S doIt(S botID, S dataID) {
    print("Killing " + botID);
    killProgramID(botID);
    
    if (dataID == null) {
      print("Clearing data directory for " + botID);
      backupAndCleanProgramDir(botID);
    } else {
      print("Unpacking " + dataID + " for " + botID);
      unpackProgramData(botID, dataID);
    }
    
    print("Starting " + botID);
    nohupJavax("" + parseSnippetID(botID));
    
    return "All done.";
  }
  
  static void unpackProgramData(S botID, S dataID) {
    // TODO: check if the same data is there already,
    // then skip all this.
    
    if (sameSnippetID(dataID, "#1001471"))
      dataID = null;
    
    backupAndCleanProgramDir(botID);
    if (dataID != null)
      zip2dir(loadLibrary(dataID), new File(userHome()), "JavaX-Data/" + formatSnippetID(botID));
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, dhtvkmknsjym, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001337
Snippet name: Bot Receiving Bot
Eternal ID of this version: #1001337/1
Text MD5: 2d55ee1e865c690a097d34bdbd517b9e
Transpilation MD5: b78f3b27510d026c76dd3475d863882d
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-10-17 19:17:21
Source code size: 1753 bytes / 63 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 532 / 997
Referenced in: [show references]