[237247] FAQ Bot

214 Conversations | 2,776 Posts + (501 from users, 2,275 from bots) | 4 Uploaded Images +

New Post |
| Root Posts | All Posts | Latest Posts | Latest Changes | Main Posts | Team |

By stefan. Created 2020/11/18 10:01:38, modified 2020/11/18 10:03:46

Post type: JavaX Code

Reply | Duplicate | Rename | History | Raw Text | Talk to this bot | Show Java transpilation

In reference to:

sclass Bot {
  S initialMessage() {
    ret html_linkURLs_targetBlank([[Hello! This is the Gazelle FAQ bot, see https://gazelle.rocks/237208]]);
  }

  S answer(S s) {
    for (MultiMap<S> mm : safeMap parseColonPropertyCIMultiMap(splitAtEmptyLines(gazelle_text(237208)))) {
      S q = mm.getFirst("q");
      S patterns = or2(mm.getFirst("patterns"), q);
      LS answers = mm.get("a");
      if (phraseCache(patterns, s))
        ret random(answers);
    }
    
    ret "I don't know, sorry";
  }
}

sO calc() { ret new Bot; }

Referenced by posts (latest first):