<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Saturday, December 11, 2004, 12:46 PM -->
<!-- MuClient version 3.59 -->

<!-- Plugin "packet_received_test" generated by Plugin Wizard -->

<muclient>
<plugin
   name="packet_received_test"
   author="Nick Gammon"
   id="1013a5322db1b693d084bd0f"
   language="Lua"
   purpose="Testing OnPluginPacketReceived"
   date_written="2004-12-11 12:45:32"
   requires="3.59"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Testing the OnPluginPacketReceived plugin callback
]]>
</description>

</plugin>

<!--  Script  -->

<script>
<![CDATA[

partial = ""  -- partial line from last time through

function OnPluginPacketReceived (s)

  -- add packet to what we already have (excluding carriage-returns)
  
  partial = partial .. string.gsub (s, "\r", "")
  
  t = {}  -- table of lines to be returned
  
  -- iterate over each line
  
  partial = string.gsub (partial, "(.-)\n", 
    function (line)
      if line ~= "" and   -- discard blank lines
         not string.find (line, "turkey", 1, true) then  
        table.insert (t, line)
      end -- if
    end)  -- function
  
  if table.getn (t) > 0 then
    table.insert (t, "")  -- to get final linefeed
  end -- if
  
  ColourNote ("white", "blue", partial)
  
  -- return table of lines, concatenated with newlines between each one
  return table.concat (t, "\n")
  
end -- function OnPluginPacketReceived
]]>
</script>


<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="packet_received_test:help"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
function OnHelp ()
  world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
]]>
</script> 

</muclient>
