jam/test/test-http-POST.js

22 lines
672 B
JavaScript

// ag-0.de: # /opt/node-v10.23.1-linux-x86/bin/node WWW/software/wclbot
CleverBot = {
ask : function (line,cb) {
http.POST(CleverBot.url,{
say:line,
session:CleverBot.session,
context:CleverBot.context
}, function (response) {
// console.log(response);
CleverBot.session=response.session;
CleverBot.context.push(line); CleverBot.context.push(response.answer);
cb(response.answer)
});
},
context : [],
reset : function () { CleverBot.session=null;CleverBot.context=[] },
session : null,
url : 'http://ag-0.de:12121',
}
print('Asking cleverbot: Who are you? Answer:');
CleverBot.ask('Who are you?',print);