Away script

From Scriptwiki
Revision as of 16:23, 15 September 2005 by Tovrleaf (talk | contribs) (edited links)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This is an example of a basic away script, including autoaway and option to send a message when you're away/back.

;away alias
alias away {
 ;if $1 does exist, you'll be marked as away, else you're back
 if ($1) {
   ;this is to send an /ame when you set yourself as away
   ame is away: $1-
   ;the ! is so the normal away alias will be used.
   !away $1-
 }
 else {
   if ($away) {
     ;send an /ame when you're back :]
     ame is back from $1-
     !away
   }
   else {
     echo -a error, you were not marked as away yet, so you can't use /away
     echo -a to be back again :)
   }
 }
}
;this alias is to check if you're active
alias awaycheck {
 ;%t is the var wich is after how many seconds you should be marked as away auto
 var %t = 600
 ;the autoaway will only work if you're not away yet, and if $idle (the amount of seconds you've done nothing in mirc)
 ;is bigger then %t
 if (!$away) && ($idle >= %t) {
   ;the ame message when you are auto away is considered as being annoying, so we'll disable that by using !away
   !away autoaway after %t seconds
 }
}
;start a timer for the awaycheck
on *:connect:{
 ;the . is so you won't see "* Timer 1 activated" when you start it
 ;the 0 is to let it run forever, or till you turn mirc off or your computer crashes :)
 ;30 means every 30 seconds
 .timer 0 30 awaycheck
}
;add here all channels you don't want you're /ame messages to appear in
alias nochannels {
 ;return is to make it an identifyer, so you can use $nochannels wich will give everything you put behind return
 return #help.script,#feds,#help,#other_channels
}
;ame alias, wich doesn't send the message to all channels
alias ame {
 ;make %a 1, and clear %t
 var %a = 1,%t
 ;the while runs as long as %a is lower or equal to $chan(0)
 while (%a <= $chan(0)) {
   ;$istok is an identifyer wich will return $true if the $chan(%a) is in $nochannels
   if (!$istok($nochannels,$chan(%a),44)) {
     ;if $chan(%a) is not it in, add the channel to %t
     var %t = %t $+ $chr(44) $+ $chan(%a)
     ;echo in the channel the action
     echo $color(action text) -t $chan(%a) * $nick($chan(%a),$me).pnick $1-
   }
   inc %a
 }
 ;send the message to the server
 .raw PRIVMSG $right(%t,-1) $+(:,$chr(1),ACTION,$chr(32),$1-,$chr(1))
}