Idle monitor/reporter

Posted by Vaejor on Wed 25 Sep 2002 02:13 AM — 1 posts, 11,950 views.

#0
Here's a plugin I threw together.

As is, it should be safe for everyone.

Some MUDs may not like anti-idle triggers/timers(eg. making it force a command to be sent), so changing anything is at your own discretion and risk.

----------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="idle_monitor"
   author="Vaejor"
   id="ebcc5214dc5b657cd72984e4"
   language="VBscript"
   purpose="Monitor idleness, report output after specified time"
   save_state="n"
   date_written="2002-09-18 10:08:00"
   requires="3.260000"
   version="1.0"
   >
</plugin>

<!-- Scripts -->

<script>
<![CDATA[

  Const intIdleWarningStartMinutes = 30
'strMessageText: %m shows minutes, %s shows seconds
  Const strMessageText = "*-*-*-*-*- You have been idle for %m:%s -*-*-*-*-*"
  Const strMessageForeColor = "red"
  Const strMessageBackColor = "black"

  Const intIdleWarningRepeatSeconds = 30

  Dim datLastCmdSent

  Function OnPluginSend(ByVal strData)
    IdleTimerReset
    OnPluginSend = vbTrue
  End Function

  Sub OnPluginInstall
    IdleTimerReset
  End Sub

  Sub OnPluginConnect
    IdleTimerReset
  End Sub

  Sub IdleTimerReset
    If (world.IsTimer("idle_warning_timer_message") = eOK) Then world.DeleteTimer "idle_warning_timer_message"
    world.AddTimer "idle_warning_timer", 0, intIdleWarningStartMinutes, 0, "", 1+4+1024+16384, "IdleTimerLimit"
    datLastCmdSent = Now()
  End Sub

  Sub IdleTimerLimit(ByVal strTimerName)
    world.AddTimer "idle_warning_timer_message", 0, 0, intIdleWarningRepeatSeconds, "", 1+1024+16384, "IdleTimerMessage"
    IdleTimerMessage "IdleTimerLimit"
  End Sub

  Sub IdleTimerMessage(ByVal strTimerName)
    Dim varMinutes
    Dim varSeconds
    Dim strMsgSend

    varSeconds = Fix(CSng(Now - datLastCmdSent) * 86400) Mod 86400
    varMinutes = Fix(varSeconds / 60)
    varSeconds = varSeconds Mod 60

    strMsgSend = strMessageText
    strMsgSend = Replace(strMsgSend, "%m", varMinutes)
    If (InStr(1, strMsgSend, " %s") = 0 And varSeconds < 10) Then varSeconds = "0" & varSeconds
    strMsgSend = Replace(strMsgSend, "%s", varSeconds)

    world.ColourNote strMessageForeColor, strMessageBackColor, strMsgSend
  End Sub
]]>
</script>

</muclient>