<?xml version="1.0" encoding="ISO-8859-1"?>
<cookbook xmlns:al="http://www.logilab.org/namespaces/Narval/1.2">

<al:recipe name="simple-demo">
  <al:step id="1" type="action" target="Demos.chat-demo"/>
</al:recipe>


<al:recipe name="handle-commands">
  <al:description lang="en">
    A recipe to handle Internet messages and presences produced by a message
    protocol handler (such as the Jabber protocol handler), and producing
    commands according to the incoming message.
  </al:description>
  
  <al:step id="s0" type="action" target="Basic.NOP"/>
  <al:step id="s1" type="action" target="Chat.is-for-me"/>
  <al:step id="s2" type="action" target="Chat.ail-extract-command"/>
  <al:step id="s3" type="action" target="Basic.NOP"/>

  <al:transition id="t0">
    <al:description lang="en">filter message / presense</al:description>
    <al:in idref="s0"/>
    <al:out idref="s1"/>
    <al:condition from_context="plan" to_context="plan">
      <al:match>IIMessage(elmt)</al:match>
    </al:condition>
  </al:transition>
  <al:transition id="t1">
    <al:description lang="en">filter message / presense</al:description>
    <al:in idref="s0"/>
    <al:out idref="s3"/>
    <al:condition from_context="plan" to_context="plan">
      <al:match>IIPresence(elmt)</al:match>
    </al:condition>
  </al:transition>
  <al:transition id="t2">
    <al:in idref="s1"/>
    <al:out idref="s2"/>
  </al:transition>
  <al:transition id="t3">
    <al:in idref="s2"/>
    <al:out idref="s3"/>
  </al:transition>
</al:recipe>


<al:recipe name="presences-log" restart="yes">
  <al:step id="s1" type="action" target="Basic.NOP"/>
  <al:step id="s2" type="action" target="Presence.log-presence"/>
  <al:transition id="t1">
    <al:in idref="s1"/>
    <al:out idref="s2"/>
    <al:condition use="yes">
      <al:match>IIPresence(elmt)</al:match>
    </al:condition>
  </al:transition>
</al:recipe>

<al:recipe name="xmlrdf-export">
  <al:step id="s1" type="recipe" target="kb.xmlrdf-export"/>
  <al:step id="s21" type="action" target="Chat.data2msg"/>
  <al:step id="s22" type="action" target="Basic.write-file"/>
  <al:step id="s3" type="action" target="Basic.NOP"/>
  <al:transition id="t11">
    <al:condition>
      <al:match>ICommand(elmt).args[0] == 'im'</al:match>
    </al:condition>
    <al:in idref="s1"/>
    <al:out idref="s21"/>
  </al:transition>
  <al:transition id="t12">
    <al:condition>
      <al:match>not ICommand(elmt).args or ICommand(elmt).args[0] != 'im'</al:match>
    </al:condition>
    <al:in idref="s1"/>
    <al:out idref="s22"/>
  </al:transition>
  <al:transition id="t21">
    <al:in idref="s21"/>
    <al:out idref="s3"/>
  </al:transition>
  <al:transition id="t22">
    <al:in idref="s22"/>
    <al:out idref="s3"/>
  </al:transition>
</al:recipe>

</cookbook>