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

66
LINES

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

JavaX fragment (include)

static S voice = "Alex";
static new ThreadLocal<Boolean> pivoMode;

static L<S> matches = litlist(
  "Was machen wir heute?",
    "Frau Petersen besuchen!",
    "hallo du ey hey hi assistent sag doch mal mir na ja so yo denn eigentlich und noch alles überhaupt schönes", 
    
  "Was wollen wir da?",
    "Viel Geld beantragen",
    "und dann denn",
    
  "Ich soll dich demonstrieren",
    "Na denn man los!",
    "",
  
  "Kannst du rechnen?",
    "Na klar!",
    "auch",
    
  ""
);

static void pivoLoad() {
  load("voice");
}

static S setVoice(S v) {
  voice = v;
  save("voice");
  ret "Hallo, hier ist " + v;
}

static synchronized S answer(S s) {
  new Matches m;
  if (!attn()) ret null;
  if (!eq(getUserName (), "stefanreich") && !pivoMode. get ()) ret null;
  
  if "Alex" ret setVoice("Alex");
  if (match("Leo", s) || match("Leopold", s))
    ret setVoice("Leopold");
  if "Gudrun" ret setVoice("Gudrun");
  
  /*if (matchQuestion_dropping("Was machen wir heute?", 
    "hallo du ey hey hi assistent sag doch mal mir na ja so yo denn eigentlich und noch alles überhaupt schönes", s))
    ret whatWeDoToday;*/
    
  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);
  }
  
  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));
}

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: #1002931
Snippet name: Pivo Logic (include)
Eternal ID of this version: #1002931/1
Text MD5: a343bd7aecd69afc4e8091f6d33d4f7f
Author: stefan
Category: eleu / nl
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-04-07 17:03:41
Source code size: 1718 bytes / 66 lines
Pitched / IR pitched: No / No
Views / Downloads: 609 / 834
Referenced in: #1002922 - Pivo Bot
#1002943 - Pivo Logic English (include)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)