Source for file customtags.php

Documentation is available at customtags.php

  1. <?
  2.  
  3. /*
  4. Program E
  5. Copyright 2002, Paul Rydell
  6. This file is part of Program E.
  7. Program E is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. Program E is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Program E; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21.  
  22.  
  23. /**
  24. * Custom tags
  25. *
  26. * Contains functions that process custom, non-AIML 1.0.x specified tags
  27. * @author Paul Rydell
  28. * @copyright 2002
  29. * @version 0.0.8
  30. * @package Interpreter
  31. */
  32.  
  33.  
  34. /*
  35. INSTRUCTIONS
  36.  
  37. If you want to put custom tags into your templates you need to define functions to handle those tags in this file.
  38.  
  39. Define the function with the name ct_customtagname. Setup the function to be passed the parameters $xmlnode, $inputstar, $thatstar, and $topicstar.
  40.  
  41. After the function has been defined it will automatically be called to handle XML that matches your custom tag name.
  42.  
  43. Please review the examples below.
  44.  
  45. */
  46.  
  47.  
  48. /*
  49. Example:
  50. You want to build email capabilities into the bot and have invented an <email> tag.
  51. Example of how your new email tag will be used:
  52. <category>
  53. <pattern>EMAIL PAUL AND TELL HIM *</pattern>
  54. <template>Okay. I emailed him. <email to="paul@rydell.com"><star/></email></template>
  55. </category>
  56. */
  57.  
  58. /*
  59. function ct_email($xmlnode,$inputstar,$thatstar,$topicstar){
  60. // Capitalize the attributes
  61. $mynode=upperkeysarray($xmlnode["attributes"]);
  62.  
  63. // Get the value of an attribute
  64. $sendto=$mynode["TO"];
  65. // Process everything inside the tag
  66. $emailcontent=recursechildren(realchild($xmlnode),$inputstar,$thatstar,$topicstar);
  67.  
  68. // Send an email
  69. mail($sendto, "E-Mail from Program E", $emailcontent);
  70.  
  71. // Don't return anything to the output
  72. return "";
  73.  
  74. }
  75. */
  76.  
  77. /*
  78. Example:
  79. You want to build math capabilities into the bot and have invented an <add> tag.
  80. Example of how your new add tag will be used:
  81. <category>
  82. <pattern>PLEASE ADD * TO *</pattern>
  83. <template>The answer is <add><star index="1"/>,<star index="2"/></add></template>
  84. </category>
  85. */
  86.  
  87. /*
  88. function ct_add($xmlnode,$inputstar,$thatstar,$topicstar){
  89. $total=0;
  90.  
  91. # Process everything inside the tag
  92. $numberstoadd=recursechildren(realchild($xmlnode),$inputstar,$thatstar,$topicstar);
  93.  
  94. # Split the numbers into an array
  95. $numberstoadd=split(",",$numberstoadd);
  96.  
  97. # Total up the numbers
  98. foreach($numberstoadd as $x)
  99. $total += $x;
  100.  
  101. # Return the answer
  102. return $total;
  103.  
  104. }
  105. */
  106.  
  107. ?>

Documentation generated on Wed, 12 Jan 2005 12:24:45 +0100 by phpDocumentor 1.3.0RC3