33 lines
1022 B
PHP
Executable File
33 lines
1022 B
PHP
Executable File
<?php
|
|
include_once("src/CamsAI/Engine.class.php");
|
|
// @TODO: Refactor this example program into an AI component library for use in other applications.
|
|
use CamsAI;
|
|
use System\Runtime\InteropServices;
|
|
|
|
define("APP_PATH", __DIR__."/bot");
|
|
|
|
|
|
// @TODO: Replace the username with the username of the user in the OS, or as specified by constructor.
|
|
$AI = new \CamsAI\Engine(APP_PATH, $_ENV['Username']);
|
|
|
|
while(true) {
|
|
echo("You>");
|
|
$message = \System\Console::Readline();
|
|
// Send request and include our own OOB parser callback to be called after the engine's default parser
|
|
$response = $AI->SendChatRequest($message, $AI->user, "parse_oob");
|
|
|
|
// Echo the trimmed response
|
|
echo("AI>".trim($response['message'])."\r\n");
|
|
|
|
}
|
|
|
|
function parse_oob($OobXML)
|
|
{
|
|
$xml = simplexml_load_string($OobXML);
|
|
foreach ($xml as $tag => $value)
|
|
{
|
|
// Created handler for XML
|
|
\System\Diagnostics\Debug::WriteLine("[Application OOB Parser] OOB Tag Detected: ". $tag. "\r\n");
|
|
var_dump($value);
|
|
}
|
|
} |