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

48
LINES

< > BotCompany Repo | #1002943 // Pivo Logic English (include)

JavaX fragment (include)

static new ThreadLocal<Boolean> pivoMode;

!include #1002953 // Point Bot

static L<S> matches = litlist(
  "Are you William?",
    "Oh sure I am!",
    "the my guy called a", 
    
  ""
);

static void pivoLoad() {
  loadPointBot();
}

static synchronized S answer(S s) {
  new Matches m;
  if (!attn()) ret null;
  if (!eq(getUserName (), "stefanreich") && !pivoMode. get ()) ret null;
  
  try answer answerPointBot(s);

  for (int i = 0; i+2 < l(matches); i += 3) {
    S pat = matches.get(i);
    S words = matches.get(i+2);
    if (matchQuestion_dropping(pat, words, s))
      ret matches.get(i+1);
  }
  
  // addition
  
  L<S> tok = codeTokensOnly(javaTok(s));
  
  if (l(tok) == 3 && eq(get(tok, 1), "+")
    && isInteger(get(tok, 0)) && isInteger(get(tok, 2)))
    ret str(bigint(get(tok, 0)).add(bigint(get(tok, 2))));

  ret s;
}

static boolean matchQuestion_dropping(S pat, S wordsToDrop, S s) {
  ret match(pat, dropWords(s, wordsToDrop));
}

static void log(S bot, S text) {
  logMap(logName, "time", now(), "bot", bot, "msg", text);
}

Author comment

Began life as a copy of #1002931

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1002943
Snippet name: Pivo Logic English (include)
Eternal ID of this version: #1002943/1
Text MD5: 330738d0b9744ee69ea1766a858cf034
Author: stefan
Category: eleu / nl
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-04-10 18:32:04
Source code size: 1099 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 728 / 836
Referenced in: [show references]