<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient [
  <!ENTITY afk_command "afk" > 
  <!ENTITY timer_mins "5" > 
  <!ENTITY timer_secs "0" > 
  <!ENTITY afk_message "You are now afk." > 
  <!ENTITY not_afk_message "You are no longer afk." > 
]>

<!--

Customising (change above entities) ...

Change "afk_command" to whatever sets you AFK.
  Default: afk
   
Change "timer_mins" to be the number of minutes before you are AFK.
	Default: 5 minutes
	
Change "timer_secs" to be the number of seconds before you are AFK.
	Default: 0 seconds

In other words, to be AFK after 2.5 minutes, timer_mins would be 2, and 
timer_secs would be 30.

-->

<!-- Saved on Saturday, October 08, 2005, 10:37 AM -->
<!-- MuClient version 3.66 -->

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

<muclient>
<plugin
   name="AFK_timer"
   author="Nick Gammon"
   id="4d167d47cac26fb36e161e48"
   language="Lua"
   purpose="Sends AFK to the MUD when 5 minutes elapse"
   date_written="2005-10-08 10:32:50"
   requires="3.52"
   version="1.0"
   >
<description trim="y">
<![CDATA[
After the specified interval (default 5 minutes) elapse, sends "afk" to the MUD.
]]>
</description>

</plugin>

<!--  Timers  -->

<timers>
  <timer name="afk_timer" 
         second="&timer_secs;"  
         minute="&timer_mins;"  
         send_to="12"    
         enabled="y"
>
  <send>
    ColourNote ("salmon", "", "You are now AFK.")
    Send ("&afk_command;")
    EnableTimer ("afk_timer", 0)
  </send>
  </timer>
</timers>

<!--  Triggers -->

<triggers>
  <trigger
   enabled="y"
   match="&not_afk_message;"
   send_to="12"
  >
  <send>
    FixTimer ()  -- make sure timer is back on
  </send>
  </trigger>
</triggers>

<triggers>
  <trigger
   enabled="y"
   match="&afk_message;"
   send_to="12"
  >
  <send>
    EnableTimer ("afk_timer", 0) -- make sure timer is off
  </send>
  </trigger>
</triggers>


<!--  Script  -->


<script>
<![CDATA[

-- when they type something, reset AFK status

function OnPluginCommand (sText)
  FixTimer ()
  return true  -- process the command
end

-- when you connect to the MUD, presumably you are not AFK

function OnPluginConnect ()
  FixTimer ()
end

-- shared routine to handle turning AFK off

function FixTimer ()
  if GetTimerOption ("afk_timer", "enabled") == 0 then
    ColourNote ("salmon", "", "You are no longer AFK.")
  end

-- turn timer back on
  EnableTimer ("afk_timer", 1)

-- make sure the full time interval elapses
  ResetTimer ("afk_timer")

end
]]>
</script>

</muclient>
