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

63
LINES

< > BotCompany Repo | #1004118 // phonePublicCommBot

JavaX fragment (include)

static Map<S, Long> phonePublicCommBot_clients = synchroHashMap();
sbool phonePublicCommBot_brave; // true = expose yourself on public IP

static bool phonePublicCommBot() {
  if (eq("true", trim(readTextFile(getProgramFile("#1004118", "brave")))))
    phonePublicCommBot_brave = true;
    
  if (doIHavePublicIPs()) {
    if (phonePublicCommBot_brave)
      print("NOTE: WE'RE BRAVE (PUBLIC IP)!!!!!!!");
    else {
      print("JavaX Safety Note: We're on a public IP!! Not starting public comm bot.");
      false;
    }
  }
  
  Android3 a = new Android3("Public Comm Bot at " + getComputerID() + ".");
  a.publicOverride = true;
  a.useMultiPort = false;
  a.startPort = 4999;
  a.console = false;
  a.responder = makeResponder(new O {
    S answer(S s) {
      DialogIO io = makeAndroid3_io.get();
      if (io != null)
        phonePublicCommBot_clients.put(io.getSocket().getInetAddress().getHostAddress(), now());

      new Matches m;
      
      if "clients last seen"
        ret structure(phonePublicCommBot_clients);
        
      if "your ips"
        ret structure(getMyIPs());
        
      if "test"
        return "test!";
        
      if "ping"
        return "pong!";
        
      if (match3("please forward to bot *: *", s, m)) {
        S bot = unquote(m.m[0]);
        S line = unquote(m.m[1]);
        ret sendToLocalBotOpt(bot, line);
      }
      
      if "please forward to vm: *"
        ret sendToThisVM($1);
      
      null;
    }
  });
  
  makeAndroid(a);
  if (a.port != a.startPort) {
    //print("Could not register port " + a.startPort + ", disposing.");
    a.dispose();
    false;
  }
  print("Public Comm Bot started.");
  true;
}

Author comment

Began life as a copy of #1004080

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004118
Snippet name: phonePublicCommBot
Eternal ID of this version: #1004118/2
Text MD5: e8a078c73912b20b9f21add6a8794914
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-05-03 14:58:37
Source code size: 1745 bytes / 63 lines
Pitched / IR pitched: No / No
Views / Downloads: 595 / 1086
Version history: 1 change(s)
Referenced in: [show references]