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

68
LINES

< > BotCompany Repo | #1008534 // Stefan's Thought Bot [dev.]

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

Libraryless. Click here for Pure Java version (8048L/54K/178K).

!7

static Pair<SS, SS> text2tag, tag2answer;
static SS text2tag_symbols;
static new ThreadLocal<Session> session;
static ThreadLocal<L<S>> buttons = new ThreadLocal;
static Map<S, Int> spellMap;
static L<S> countries;

concept Session {
  S cookie;
  Double lastDollarValue;
  S lastQuestion;
}

sbool debug;

svoid setSession(S cookie) {
  session.set(uniq_sync(Session, +cookie));
}

svoid clearSession(S cookie) {
  deleteConcepts(Session, +cookie);
}

p {
  db();
  
  // load stuff
  spellMap = loadSpellList(#1008389);

  veryBigConsole();
  bot();
}

sS returnQuestion(S q) {
  cset(session!, lastQuestion := q);
  ret q;
}

sS answer(S s) {
  if (session! == null) setSession("default");
  buttons.set(null);
  if (creator() == null) if "debug" set debug;
  
  S lq = session->lastQuestion;
  cset(session!, lastQuestion := null);
  
  if (eq(lq, "Would you like some tea?")) {
    if "yes" ret "Here's your tea.";
    if "no" ret "Very well then.";
  }
  
  if "test buttons" {
    buttons.set(ll("Yes", "No"));
    ret returnQuestion("Would you like some tea?");
  }

  S _s = s;
  s = levenAttract(spellMap, s);
  if (neqic(s, _s)) print("Spell-correct => " + s);

  ret "Sorry, I didn't understand that";
}

sS initialMessage() {
  ret "Stefan's Hypercube Bot here. What's up?";
}

Author comment

Began life as a copy of #1008347

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: #1008534
Snippet name: Stefan's Thought Bot [dev.]
Eternal ID of this version: #1008534/3
Text MD5: 9425357f12bdb3d0fb729ae3f7e5149c
Transpilation MD5: 67c91b8931d9258ec14d517418e081f4
Author: stefan
Category: javax / a.i.
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-06-01 17:19:15
Source code size: 1360 bytes / 68 lines
Pitched / IR pitched: No / No
Views / Downloads: 491 / 914
Version history: 2 change(s)
Referenced in: #1008533 - Stefan's Web Chat Bot [dev.]