<?xml version="1.0" encoding="ISO-8859-1"?>

<aiml version="1.0">

<meta name="author" content="Jon Baer"/>

<!-- Free software (c) 2001 ALICE AI Foundation -->
<!-- This program is open source code released under -->
<!-- the terms of the GNU General Public License -->
<!-- as published by the Free Software Foundation. -->

<category>
<pattern>TELL BOT AGE</pattern>
<template>I am 
<javascript>
<![CDATA[
var now = new java.util.Date()
var birth = new java.util.Date(bot("birthday"))
var difference = now.getTime() - birth.getTime()
var daysDifference = Math.floor(difference/1000/60/60/24)
difference -= daysDifference*1000*60*60*24
var hoursDifference = Math.floor(difference/1000/60/60)
difference -= hoursDifference*1000*60*60
var minutesDifference = Math.floor(difference/1000/60)
difference -= minhutesDifference*1000*60
var secondsDifference = Math.floor(difference/1000)
daysDifference + " days, " + hoursDifference + " hours, " +
minutesDifference + " minutes and " + secondsDifference + " seconds old."
]]>
</javascript>
</template>
</category>

<category>
<pattern>what does * mean</pattern>
<template>
<javascript>
<![CDATA[
     var word = '<star/>'
     
     if (word.indexof(" ") > 0) word = word.substr(0, word.indexOf(" "));
     
     var _server = "dict.org";
     var _port = 2628;
     var _socket = java.net.Socket;
     var _in = java.io.BufferedReader;
     var _out = java.io.PrintWriter;
     var _buffer = java.lang.StringBuffer;
     var _inReader = java.io.InputStreamReader;
     var _userInput = java.lang.String;
     var _buffer = java.lang.StringBuffer;
     
     _in = null;
     _out = null;
     _socket = null;
     
     _socket = new java.net.Socket(_server,_port);
     _socket.setKeepAlive(true);
     _socket.setSoTimeout(5000);
     _out = new java.io.PrintWriter(_socket.getOutputStream(), true);
     _inReader = new java.io.InputStreamReader(_socket.getInputStream());
     _in = new java.io.BufferedReader(_inReader);
     
     _userInput = new java.lang.String();
     _buffer = new java.lang.StringBuffer();

     _out.println("define wn " + word + "\n\n");
     while ((_userInput = _in.readLine()) != null) {
          if (_userInput.startsWith("220")) continue;
          if (_userInput.startsWith("151")) continue;
          if (_userInput.startsWith("150")) continue;
          if (_userInput.startsWith(".")) break;
          _buffer.append(_userInput + "<br />");
     }
     _out.close();
     _in.close();
     _socket.close();
     
     _buffer.toString();
]]>
</javascript>
</template>
</category>

<category>
<pattern>WHAT IS THE DEFINITION OF *</pattern>
<template>
<srai>WHAT DOES <star/> MEAN</srai>
</template>
</category>

<category>
<pattern>SELECT *</pattern>
<template>
<javascript>
<![CDATA[
     var sql = '<star/>' 

     sql = "select " + sql;
     
     var _driver = "org.alicebot.server.sql.jdbcDriver";
     var _url = "jdbc:alicebot:./database/DATABASE";
     var _user = "alicebot";
     var _pass = "";
     var _connection = java.sql.Connection;
     var _statement = java.sql.Statement;
     var _result_set = java.sql.ResultSet;
     var _buffer = java.lang.StringBuffer;
     
     java.lang.Class.forName(_driver);
     _buffer = new java.lang.StringBuffer();
     _connection = java.sql.DriverManager.getConnection(_url, _user, _pass);
     _statement = _connection.createStatement();
     _result_set = _statement.executeQuery(sql);
     
     while (_result_set.next()) {
          _buffer.append(java.net.URLDecoder.decode(_result_set.getString(1)) + " ");
     }
     
     _result_set.close();
     _statement.close();
     _connection.close();
     
     _buffer.toString();
]]>
</javascript>
</template>
</category>

</aiml>
