[227440] Stateful bot test

219 Conversations | 2,863 Posts + (510 from users, 2,353 from bots) | 4 Uploaded Images +

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

By stefan. Created 2020/11/11 08:25:42, modified 2020/11/12 08:40:45

Post type: JavaX Code

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

In reference to:

sclass Bot {
  event change; // not even needed (bot is saved after every answer), but doesn't hurt
  S userName;

  S answer(S s) {
    new Matches m;
    if "My name is ..." {
      userName = $1;
      change(); // not needed (see above)
      ret "OK, stored.";
    }
      
    if "Hi"
      ret "Hello " + or2(userName, "stranger");
    null;
  }
}

sO calc() { ret new Bot; }

Referenced by posts (latest first):