!747 m { p { makeAndroid3("Bot receiving bot."); } static synchronized S answer(S s, L 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)); } }