NullLogic

...

#!/usr/bin/nsp function print_response(res) { if (_ENV['TERM']!=null) { print("\e[01;37;40m", res, "\e[00m\n\n"); } else { print(res, "\n\n"); } return; } function echo(input, key) { x=string.tolower(string.sub(string.istr(input, key), string.len(key))); while (string.sub(x, 0, 1)==' ') x=string.sub(x, 1); x=transpose(x); return x; } function transpose(input) { t=string.split(input, " "); output=""; for (i=0;i<sizeof(t);i++) { match=false; if (i>0) output+=" "; for (j=0;j<sizeof(trans);j++) { if (t[i]==trans[j][0]) { output+=trans[j][1]; match=true; break; } } if (match==false) output+=t[i]; } return output; } //dl.load("regex"); //if (typeof(regex.replace)!='function') { print("you need regex.replace()\n"); exit; } if (typeof(io.gets)!='function') { print("you need io.gets()\n"); exit; } if (!include(_filepath+"/lis-l.ns")) { print("can't find language file lis-l.ns\n"); exit; } if (typeof(_SERVER)=='table') { //rc=dl.load("ext"); //global X=xml.read(file.readall("/home/null/gw/aiml/startup.xml")); //global Y=xml.read(file.readall("/home/null/gw/aiml/std-65percent.aiml")); //global Z=xml.read(file.readall("/home/null/gw/aiml/std-pickup.aiml")); //print("<pre>",serialize(X),"</pre>"); } print("lis\n\n"); i=math.rand(sizeof(greetings)); print_response(greetings[i]); for (loop=0;;loop++) { in=" "+io.gets()+" "; print("\n"); try { // reload the response file. good for testing changes. if (!include(_filepath+"/lis-l.ns")) { print("can't find language file lis-l.ns\n"); exit; } in=string.tolower(in); if (sizeof(in)<1) { i=math.rand(sizeof(blankres)); print_response(blankres[i]); continue; } match=-1; key=""; for (i=0;i<sizeof(keyphrases);i++) { if (typeof(keyphrases[i][0])=='table') { for (j=0;j<sizeof(keyphrases[i][0]);j++) { if (string.istr(in, keyphrases[i][0][j])!=null) { match=i; key=keyphrases[i][0][j]; break; } } } else { if (string.istr(in, keyphrases[i][0])!=null) { match=i; key=keyphrases[i][0]; } } if (match>=0) break; } if (match>=0) { if (typeof(keyphrases[match][1])=='table') { i=math.rand(sizeof(keyphrases[match][1])); if (typeof(keyphrases[match][1][i])=='function') { print_response(keyphrases[match][1][i](in, key)); } else { print_response(keyphrases[match][1][i]); } } else { print_response(keyphrases[match][1]); } } else { i=math.rand(sizeof(confusedres)); print_response(confusedres[i]); } if (string.istr(in, 'bye')) break; if (string.istr(in, 'quit')) break; } catch (ex) { printf("%s", serialize(ex)); } }