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

37
LINES

< > BotCompany Repo | #1003120 // Bob (dev.)

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

Libraryless. Click here for Pure Java version (2150L/15K/49K).

!752

static S name = "Bob";
static new L<S> knownBots;
static bool saidThatIAmABot;

p {
  print("Bob Print Test, print_log=" + systemHashCode(print_log) + ", local_log=" + systemHashCode(local_log));
  thread "Bob" {
    simpleChatListen();
    simpleChatPresence(name);
    simpleChatPost("Hey yo, I'm " + name + "!");
    simpleChatWait();
    simpleChatPost("Any bots here?!");
  }
}

static void process(L msgs) {
  for (O msg : msgs) {
    S text = getString(msg, "text");
    S user = getString(msg, "user");
    print(name + ": msg " + quote(text) + " " + quote(user));
    if (eq(user, name)) continue;
    
    if (eqic(text, "I'm a bot") && !knownBots.contains(user)) {
      setAdd(knownBots, user);
      simpleChatPost("Cool. Hello " + user + "!"
        + (saidThatIAmABot ? "" : " I'm a bot too."));
      //saidThatIAmABot = true;
    }
    
    if (eqic(text, "Any bots here?!") && !saidThatIAmABot) {
      simpleChatPost("I'm a bot");
      //saidThatIAmABot = true;
    }
  }
}

Author comment

Began life as a copy of #1003092

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1003120
Snippet name: Bob (dev.)
Eternal ID of this version: #1003120/1
Text MD5: 588243bf3f2be1d454242446968f30e8
Transpilation MD5: 67ee8bde42f6869e3560b3ce3da73d9e
Author: stefan
Category: eleu / nl
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-06-06 00:55:52
Source code size: 1035 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 674 / 1195
Referenced in: #1003122 - John (dev.)
#1003251 - Duplicate of RoboChat Test - with a bot!
#3000382 - Answer for ferdie (>> t = 1, f = 0)