Difference between revisions of "Away script"

From Scriptwiki
Jump to: navigation, search
 
(edited links)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
This is an example of a basic away script, including autoaway and option to send a message when you're away/back.
 
This is an example of a basic away script, including autoaway and option to send a message when you're away/back.
  
  <nowiki>;away alias
+
  ;away alias
alias away {
+
[[Aliases|alias]] away {
;if $1 does exist, you'll be marked as away, else you're back
+
  ;if $1 does exist, you'll be marked as away, else you're back
if ($1) {
+
  [[If-Then-Else|if]] ([[$1-|$1]]) {
  ;this is to send an /ame when you set yourself as away
+
    ;this is to send an /ame when you set yourself as away
  ame is away: $1-
+
    [[ame]] is away: [[$1-]]
  ;the ! is so the normal away alias will be used.
+
    ;the ! is so the normal away alias will be used.
  !away $1-
+
    !away $1-
 +
  }
 +
  [[If-Then-Else|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 :)
 +
    }
 +
  }
 
  }
 
  }
  else {
+
  ;this alias is to check if you're active
  if ($away) {
+
alias awaycheck {
;send an /ame when you're back :]
+
  ;%t is the var wich is after how many seconds you should be marked as away auto
    ame is back from $1-
+
  [[var]] %t = 600
    !away
+
  ;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
  else {
+
  if (!$away) && ($idle >= %t) {
    echo -a error, you were not marked as away yet, so you can't use /away
+
    ;the ame message when you are auto away is considered as being annoying, so we'll disable that by using !away
    echo -a to be back again :)
+
    !away autoaway after %t seconds
  }
+
  }
 
  }
 
  }
}
+
;start a timer for the awaycheck
;this alias is to check if you're active
+
on *:[[on connect|connect]]:{
alias awaycheck {
+
  ;the . is so you won't see "* Timer 1 activated" when you start it
;%t is the var wich is after how many seconds you should be marked as away auto
+
  ;the 0 is to let it run forever, or till you turn mirc off or your computer crashes :)
var %t = 600
+
  ;30 means every 30 seconds
;the autoaway will only work if you're not away yet, and if $idle (the amount of seconds you've done nothing in mirc)
+
  .[[timer]] 0 30 awaycheck
;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
 
 
  }
 
  }
}
+
  ;add here all channels you don't want you're /ame messages to appear in
;start a timer for the awaycheck
+
alias nochannels {
on *:connect:{
+
  ;return is to make it an identifyer, so you can use $nochannels wich will give everything you put behind return
;the . is so you won't see "* Timer 1 activated" when you start it
+
  [[return]] #help.script,#feds,#help,#other_channels
  ;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
+
  ;ame alias, wich doesn't send the message to all channels
.raw PRIVMSG $right(%t,-1) $+(:,$chr(1),ACTION,$chr(32),$1-,$chr(1))
+
alias ame {
}</nowiki>
+
  ;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_loops|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))
 +
}
 +
 
 +
[[Category:Script Archive]]

Latest revision as of 16:23, 15 September 2005

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))
}