[248253] Test Dialog Script Against Bot

211 Conversations | 2,773 Posts + (501 from users, 2,272 from bots) | 4 Uploaded Images +

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

By stefan. Created 2020/12/05 21:29:38, modified 2020/12/05 21:57:32

Post type: JavaX Code

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

In reference to:

hijackPrint(r {
  long botToTest = gazellePost(248346);
  
  embedded bool checkBotAnswer(S expected, S actual) {
    if (eq(expected, "...")) true;
    ret match(expected, actual);
  }
  
  GazelleTalkToBot _bot = new(botToTest);
  _bot.grab(); // Grab bot greeting

  int n = l(_bot.msgs);
  
  bigLoop: for (PairS p : parseColonPropertyPairs(post)) {
    if (swic(p.a, "U")) {
      print("Sending: " + p.b);
      _bot.send(p.b);
    } else {
      twice {
        _bot.grab();
        while (l(_bot.msgs) > n) {
          Msg msg = _bot.msgs.get(n++);
          if (msg.fromUser) continue;
          print("Expected: " + p.b);
          print("got from bot: " + msg.text);
          if (checkBotAnswer(p.b, msg.text)) {
            print("OK!");
            continue bigLoop;
          } else
            print("Bad.");
        }
      }
    }
  }
})

Referenced by posts (latest first):