Away script with Auto away after Idle (3 versions)

By `666 on Jun 10, 2011

THERE ARE THREE VERSIONS OF THIS SCRIPT.
VERSION ONE- The Script in the codebox.
VERSION TWO- Scroll down and look for something to tell you to replace some coding.
VERSION THREE- Is at the bottom of this description.

Was just bored, so it's not the best of scripting. It's an away script that is controlled through menus. (You can still do /away and /back, of course). It includes an auto away after "x" minutes idled (Client sided idle time). You can edit any of the custom attributes of the script by right clicking in any channel, query, or status window.
-You may set a default reason for going away.
-Away after specified time idle.
-Choose to message or describe (/me) in the channels for /back and /away.
-Ability to reset back to the default of the script. Instead of just doing /unset for the vars yourself.
-A fairly "Newby" friendly script, as it tells you when you click on everything what it does, and what you should do.
-Ability to add your Time Zone (You have to set it in the menu) in /away and /back.
-Logs the highlights, if you wish. (Added 6-12-11)
-One-time response to a highlight if you are away. (Added 6-12-11)
-Version 1-2 use menu's for setup, version 3 uses dialog.

I think that's just about everything.
Again, I did this completely out of boredom and in just about 30 minutes. I'm pretty sure I've tested everything and it works correctly, but there may be a couple bugs.
Constructive criticism is welcome.

(If you're wondering why I used menus, it's because just about everybody makes them with dialog, so I felt like being different)

VERSION 2 -If you wish to specify your own highlights, instead of using mIRC's built in highlight dialog replace:

on *:TEXT:*:#:{ 
  if (($highlight) && ($highlight($1-)) && ($1- !isnum)) {  
    $loghl($1-)
    if (%left.at) && (!$hget(hlnames,$nick)) {
      notice $nick (One-Time Response) I am currently away - Reason for leaving: %away.reason - I am leaving at %left.at $iif(%away.timezone,$v1,$null) 
      hadd -m hlnames $nick
    }
  }
}

With

on *:TEXT:*:#:{ 
  if (!%mdl) set %mdl yes
  if ($ckhls($1-) isin %Away.hls || $istok($1-,$me,32)) {
    $loghl($1-)
    if (%left.at) && (!$hget(hlnames,$nick)) {
      notice $nick (One-Time Response) I am currently away - Reason for leaving: %away.reason - I am leaving at %left.at $iif(%away.timezone,$v1,$null) 
      hadd -m hlnames $nick
    }
  }
} 
alias ckhls { 
  var %x 0, %hls $numtok(%Away.hls,44)
  while (%x <= %hls) {
    inc %x
    var %checkhl $($gettok(%Away.hls,%x,44),2)
    if ($istok($1-,%checkhl,32)) return %checkhl
  }
  return $false
}

VERSION THREE

;;Away Script Version 3 created out of boredom by `666;;
;;To go away or come back you can right click in a channel, query, or status window. 
;;Or you may also just do /away and /back;;
;;All of the away settings may be configured by right clicking in a channel, query, or status window;;
;;For the Highlight Logs and Highlight Response to work, you must specify what you wish;;
;;to Highlight you in the Dialog.;;
menu channel,query,status {
  Away Dialog:{ /dialog -mdien away-back away-back | did -m away-back 36 | unset %hidle
    if (%away.hls) {
      var %x 1
      while (%x <= $numtok(%away.hls,44)) {
        did -a away-back 35 $gettok(%away.hls,%x,44)
      inc %x }
    }
  }
}
dialog Default-Msg {
  title "Default Msg"
  size -1 -1 400 80
  option pixels
  text "Put Your default msg here", 1, 10 10 300 20
  edit "", 2, 10 30 300 20
  button "Ok", 3, 320 30 65 20, push
}
on 1:dialog:Default-Msg:sclick:3: {
  if ($did(2)) {
    set %default.msg $did(2)
    dialog -x Default-Msg
  }
}
on 1:dialog:away-back:sclick:25: {
  dialog -dmien default-msg default-msg
}
dialog away-back {
  title "Away Back"
  size -1 -1 310 300
  option pixels
  tab "Away Settings", 1, 5 5 302 295
  tab "Away and Back", 2
  tab "Away Msg Config", 3
  button "Away<Default>", 4, 10 50 90 20, push tab 2 
  button "Away<Reason>", 5, 10 100 90 20, push tab 2 
  button "Back", 14, 10 150 65 20, push tab 2 
  button "Ok", 8, 165 270 65 20, push
  button "Cancel", 9, 235 270 65 20, push
  text "", 15, 10 200 250 25, tab 2
  edit "", 6, 105 100 150 20, tab 2
  text "Which channel would you like to add to halt? (To add multiple, seperate each channel by a comma)", 16, 10 50 250 100, tab 3
  edit "", 17, 10 80 150 20, tab 3
  button "Halt", 22, 170 80 65 20, push tab 3
  text "Which channel would you like to remove from halt?", 18, 10 120 250 100, tab 3
  edit "", 19, 10 140 150 20, tab 3
  button "Unhalt", 23, 170 140 65 20, push tab 3
  text "", 20, 10 180 200 50, tab 3
  list 21, 10 200 200 81, autohs autovs return multi tab 3
  text "", 24, 10 260 120 30, tab 3
  button "Default", 25, 20 50 65 20, push tab 1
  check "Idle away (In minutes)", 26, 20 90 125 20, tab 1
  check "Me", 27, 20 120 70 20, tab 1
  check "Amsg", 28, 20 140 70 20, tab 1
  text "Timezone:", 29, 20 162 50 100, tab 1
  edit "", 30, 75 160 150 20, tab 1
  check "HL Logging", 31, 20 270 70 20, tab 1
  text "HL Words:", 32, 20 205 50 50, tab 1
  edit "", 33, 75 200 150 20, tab 1
  button "Add", 34, 230 200 65 20, push tab 1
  list 35, 20 225 200 65, autohs autovs return multi tab 1
  edit "", 36, 155 90 100 20, tab 1
  text "Seperate each word by a comma. (HL Words)", 37, 60 180 230 20, no wrap tab 1
}  
on 1:dialog:away-back:sclick:34: {
  if ($did(33)) {
    set %away.hls $did(33)
    if (%away.hls) {
      var %x 1
      did -r away-back 35
      while (%x <= $numtok(%away.hls,44)) {
        did -a away-back 35 $gettok(%away.hls,%x,44)
      inc %x }
    }
  }
}
on 1:dialog:away-back:sclick:31: {
  if (!%hllog) { set %hllog on | halt }
  if (%hllog) { unset %hllog }
}
on 1:dialog:away-back:sclick:26: {
  if (!%hidle) { set %hidle on | did -n away-back 36 | halt }
  if (%hidle) { did -m away-back 36 | unset %hidle }
}
on 1:dialog:away-back:sclick:27: {
  if ($did(27)) { did -u away-back 28 28 | did -c away-back 27 27 | set %Away.meormsg /me the channel }
}
on 1:dialog:away-back:sclick:28: {
  if ($did(28)) { did -u away-back 27 27 | did -c away-back 28 28 | set %Away.meormsg Message the channel }
}
on 1:dialog:away-back:sclick:8: {
  if ($did(30)) { set %away.timezone $did(30) }
  if ($did(36) && %hidle) {
    set %idle.time.allowed $did(36) | .timeridle.time.check 0 30 Away.Idle.Check
  }
  if ("back" isin $did(15)) { 
    back
    did -r away-back 15
  }
  if (<default> isin $did(15)) { 
    away %default.msg
    did -r away-back 15
  }
  if ($did(6) && $did(15)) {
    away $did(6)
    did -r away-back 15 
    did -r away-back 6
  }
  if ($did(17)) {
    set %hawaymsg $addtok(%hawaymsg,$did(17),44)
    did -r away-back 17
    did -r away-back 24
    did -r away-back 21
    var %x 1
    while (%x <= $numtok(%Hawaymsg,44)) {
      did -a away-back 21 $gettok(%hawaymsg,%x,44)
    inc %x } 
  }
  if ($did(19)) {
    set %hawaymsg $remtok(%hawaymsg,$did(19),1,44)
    did -r away-back 19
    did -r away-back 24
    did -r away-back 21
    var %x 1
    while (%x <= $numtok(%Hawaymsg,44)) {
      did -a away-back 21 $gettok(%hawaymsg,%x,44)
    inc %x } 
  }
}
on 1:dialog:away-back:sclick:9: {
  if ($did(24)) { did -r away-back 24 }
  if ($did(15)) { did -r away-back 15 }
  if ($did(6)) { did -r away-back 6 }
  if ($did(17)) { did -r away-back 17 }
  if ($did(19)) { did -r away-back 19 }
}
on 1:dialog:away-back:sclick:4:{ 
  did -i away-back 15 15 You've hit the $qt($did(4)) button click Ok to continue.
  did -r away-back 6
}
on 1:dialog:away-back:sclick:3: {
  did -i away-back 20 20 You currnently have $numtok(%Hawaymsg,44) chans halted.
  did -r away-back 21
  if (%hawaymsg) {
    var %x 1
    while (%x <= $numtok(%Hawaymsg,44)) {
      did -a away-back 21 $gettok(%hawaymsg,%x,44)
    inc %x } 
  }
}
on 1:dialog:away-back:sclick:14: { did -i away-back 15 15 You've hit the "Back" button click Ok to continue. }
on 1:dialog:away-back:sclick:5: {
  if ($did(6)) {
    did -i away-back 15 15 You've hit the $qt($+($did(5),:,$did(6))) button click Ok to continue.
  }
}
alias -l Away.Idle.Check {
  if ($status == Connected) && ($idle < $calc($eval(%idle.time.allowed,1)*60)) var %Idle = off
  if (%idle != off) { 
    away I have been idle for %idle.time.allowed minutes, and am now away $iif(%default.msg,- %Default.msg,$null)
    .timeridle.time.check off
  }
}
alias away {
  set %Left.At $time(h:nn:ss-TT)
  set %Away.Reason $iif($1-,$1-,%default.msg)
  set %Away.Ctime $ctime
  if ($1 == $null) && (%default.msg == $null) { set %away.reason No reason given }
  $iif($eval(%away.meormsg,1) == /me the channel,aame,aamsg) I am now away - Reason for leaving: %away.reason - I am leaving at %left.at $iif(%away.timezone,$+($chr(40),$v1,$chr(41)),$null) 
}

alias back {
  if (%left.at == $null) { echo -a You aren't currently away! | RETURN }
  $iif($eval(%away.meormsg,1) == /me the channel,aame,aamsg) I am now back from my time away - Reason for leaving: %away.reason - I left at $+(%left.at $iif(%away.timezone,$+($chr(40),$v1,$chr(41)),$null)) and was gone for $+($duration($calc($ctime - $eval(%away.ctime,1))),$chr(46))
  unset %left.at %away.reason %away.ctime
  .hfree -sw hlnames 
  if (%idle.time.allowed) { .timeridle.time.check 0 30 Away.Idle.Check } 
}

on *:CONNECT:{
  if (%idle.time.allowed) { .timeridle.time.check 0 30 Away.Idle.Check } 
}

alias logHL {
  if (%hllog == yes) { 
    if (!$window(@Away.Logs)) window -eknz @Away.Logs
    aline -himp @Away.Logs $timestamp $nick just Highlighted you in # with the line: $+($1,$chr(33))
  }
}

on *:TEXT:*:#:{ 
  if ($ckhls($strip($1-)) isin %Away.hls || $istok($1-,$strip($me),32)) {
    $iif(%left.at,$loghl($strip($1-)),$null)
    if (%left.at) && (!$hget(hlnames,$nick)) {
      .notice $nick (One-Time Response) I am currently away - Reason for leaving: %away.reason - I left at %left.at $iif(%away.timezone,$v1,$null) 
      hadd -m hlnames $nick yes
    }
  }
} 
alias ckhls { 
  var %x 0, %hls $numtok(%Away.hls,44)
  while (%x <= %hls) {
    inc %x
    var %checkhl $($gettok(%Away.hls,%x,44),2)
    if ($istok($1-,%checkhl,32)) return %checkhl
  }
  return $false
}

alias -l aamsg {
  var %n 1
  while (%n <= $chan(0)) {
    var %chan $chan(%n)
    if (%chan !isin %hawaymsg) { var %chans $addtok(%chans,%chan,44) }
    inc %n
  }
  .msg %chans $1-
}

alias -l aame {
  var %n 1
  while (%n <= $chan(0)) {
    var %chan $chan(%n)
    if (%chan !isin %hawaymsg) { var %chans $addtok(%chans,%chan,44) }
    inc %n
  }
  .describe %chans $1-
}

Edits:
6-13-11 - Added Highlights without the mIRC dialog
6-14-11 - Fixed a forgotten closing parenthesis in the On *:TEXT:'s
6-16-11 - Added version three, dialog.

;;Away Script Version 1 created out of boredom by `666;;
;;To go away or come back you can right click in a channel, query, or status window. 
;;Or you may also just do /away and /back;;
;;All of the away settings may be configured by right clicking in a channel, query, or status window;;
;;For the Highlight Logs and Highlight Response to work, you must have mIRC highlights enabled;;
;;And every word you want to trigger it, in there.;;
menu channel,query,status {
  -
  Away Settings
  .Default Away:/set %Default.msg $$?="What would you like your default away message to be?"
  .Away After Idle:{ var %y/n $input(Would you like to go away after a set amount of time? $+($chr(40),Clicking "No" will remove any previous auto away information,$chr(41)),yvq)
    if (%y/n = $yes) {
      set %idle.time.allowed $$?="How many minutes would you like to be allowed to idle, before auto-away?"
      timeridle.time.check 0 30 Away.Idle.Check
      echo $color(info) * You will now go away automatically after %idle.time.allowed minutes.
    }
    else { 
      $iif(%idle.time.allowed,unset %idle.time.allowed,halt) 
      .timeridle.time.check off
    }
  }
  .Message Channel or "/me" channel:{ set %Away.meormsg $input(Would you like to "/me" or message the channels? (Choose from the drop-down bar).,meq,Away Settings,Message the channel,/me the channel,Message the channel)
    echo $color(info) * You have chosen for your /away and /back messages to be sent with $iif(%away.meormsg == /me the channel,/me the channels,/amsg the channels) $+ .
  }
  .Time Zone on away/back:{ $iif($input(If you wish to have your Time Zone said on away $+ $chr(44) enter it and push Ok. Can't find your's? Type it in. $+($chr(59),$chr(41)),meq,Away Settings,EST,ADST,WST,GMT/UTC,CST,AST,AEST),set %away.timezone $v1,halt)
    echo $color(info) * Time Zone set to $+(%away.timezone,$chr(46))
  }
    .Words To Highlight You: { if (%mdl != yes) { echo $color(info) * Sorry, you do not have the correct version of this script to use this. Please review http://www.hawkee.com/snippet/8711/ or talk with `666. }
    else { set %Away.hls $input((If you do not have the mIRC built in dialog) Please enter what words you would like to HL you $+ $chr(44) each seperated by a comma.,mei,Away Settings)
      echo $color(info) * $iif(%away.hls == $null,You have chosen to not set any HighLights.,The following will now highlight you: $replace(%away.hls,$chr(44),$chr(32)))
    } 
  }
  .Highlight Logging:{ if ($input(Would you like to enable Highlight Logging?,yvq) == $yes) {
      set %hllog yes
      echo $color(info) * You have set Highlight Logging to Yes.
    }
  }
  .Reset All Customs:{ 
    if ($input(Are you sure you wish to reset all your Away Settings?,yw) == $true) {
      unset %away.timezone %idle.time.allowed %away.meormsg %Default.msg %left.at %away.reason %away.ctime  %hllog %highlights
      .timeridle.time.check off
      echo $color(info) * All of your Away Customs have been reset.
    }
  }
  Away and Back
  .Away(Reason Specified):{ away $$?="What is your reason for going away? Leave blank for default away." }
  .Away(Default Reason):{ away %default.msg }
  .Back:/back
  -
}

alias -l Away.Idle.Check {
  if ($status == Connected) && ($idle < $calc($eval(%idle.time.allowed,1)*60)) var %Idle = off
  if (%idle != off) { 
    away I have been idle for %idle.time.allowed minutes, and am now away $iif(%default.msg,- %Default.msg,$null)
    .timeridle.time.check off
  }
}
alias away {
  set %Left.At $timestamp
  set %Away.Reason $iif($1-,$1-,%default.msg)
  set %Away.Ctime $ctime
  if ($1 == $null) && (%default.msg == $null) { set %away.reason No reason given }
  $iif($eval(%away.meormsg,1) == /me the channel,ame,amsg) I am now away - Reason for leaving: %away.reason - I am leaving at %left.at $iif(%away.timezone,$v1,$null) 
}

alias back {
  $iif($eval(%away.meormsg,1) == /me the channel,ame,amsg) I am now back from my time away - Reason for leaving: %away.reason - I left at $+(%left.at $iif(%away.timezone,$v1,$null),$chr(44)) and was gone for $+($duration($calc($ctime - $eval(%away.ctime,1))),$chr(46))
  unset %left.at %away.reason %away.ctime
  if (%idle.time.allowed) { .timeridle.time.check 0 30 Away.Idle.Check } 
}

on *:CONNECT:{
  if (%idle.time.allowed) { .timeridle.time.check 0 30 Away.Idle.Check } 
}

alias logHL {
  if (%hllog == yes) { 
    if (!$window(@Highlight.Logs)) window -eknz @Highlight.Logs
    aline -himp @Highlight.Logs $nick just Highlighted you in # with the line: $+($1,$chr(33))
  }
}

on *:TEXT:*:#:{ 
  if (($highlight) && ($highlight($1-)) && ($1- !isnum)) {  
    $loghl($1-)
    if (%left.at) && (!$hget(hlnames,$nick)) {
      .notice $nick (One-Time Response) I am currently away - Reason for leaving: %away.reason - I am leaving at %left.at $iif(%away.timezone,$v1,$null) 
      hadd -m hlnames $nick
    }
  }
}

Comments

Sign in to comment.
fahadmehar   -  Oct 16, 2016

Need to fix for version mIRC 7.46

 Respond  
`666   -  Sep 10, 2012

I haven't used MIRC since he first update for 7, but I will try to look into it soon. 7.25 may have changed something with the /window commands.

 Respond  
Keiro   -  Sep 09, 2012

Version 3 doesn't quite work as it should in mIRC 7.25. :| It does not appear to be correctly recognizing that the changes made to it is working.

Also, it appears your script needs to be updated for mIRC 7.25. I had a hell of a time getting it to look nice in mIRC 7.25.

Otherwise, looks like a damned good script.

 Respond  
blackvenomm666   -  Jun 10, 2011

looks good

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.