Difference between revisions of "Modifying mIRCs own Away system"

From Scriptwiki
Jump to: navigation, search
m (also a tutorial?)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
This is an example of silent but a modified away script, including autoaway, away timer in titlebar and channel menus ($iif).
+
This is an example of silent but a modified away script, including autoaway, away timer in titlebar and channel menus ([[$iif]]).
Script checks if you away or not and sets you away/back. Applys to multiple networks you in (scid, $scon).
+
Script checks if you away or not and sets you away/back. Applys to multiple networks you in ([[scid]], [[$scon]]).
 
We also get familar with our own made functions.
 
We also get familar with our own made functions.
  
  <nowiki>; this is an example of a silent but modified away script, including autoaway, away timer in titlebar and channel menus.
+
  ; this is an example of a silent but modified away script, including autoaway, away timer in titlebar and channel menus.
; script checks if you away or not and sets you away/back. Applys to multiple networks you in.
+
; script checks if you away or not and sets you away/back. Applys to multiple networks you in.
; we also get familar with our own made functions.
+
; we also get familar with our own made functions.
 
+
; halt default raws to that shows whenever you back/away in status window
+
; halt default [[:Category:Raws|raws]] to that shows whenever you back/away in status window
raw 305:*:{ halt }
+
[[Raw_305|raw 305]]:*:{ [[halt]] }
raw 306:*:{ halt }
+
[[Raw_306|raw 306]]:*:{ [[halt]] }
 
+
; $iif(this is true,do this,else do this)
+
; $iif(this is true,do this,else do this)
; $away returns to $true and $false, we check if if it's true (we are away) -> displays in channel menu "Set Back"
+
; [[$away]] returns $true whetner you've set away or $false
; and if $away is $false (we are not away) -> channel menu displays "Set Away"
+
menu channel {
menu channel {
+
  $iif($away,Set Back,Set Away):{ $iif($away,away,away $?="Away Reason") }
$iif($away,Set Back,Set Away):{ $iif($away,away,away $?="Away Reason") }
 
}
 
 
 
alias away {
 
; if $away is $false (we are not away)
 
if (!$away) {
 
  ;if $1 (word after function exists) -> we set %away.reason $1- (all words after alias)
 
  if ($1) { set %away.reason $1- }
 
  ; else if there is no words after alias, se default reason "Away"
 
  else { set %away.reason Away }
 
  ; we need this variable later in this alias, in our self made function
 
  set %since_away $date $time
 
  ; $scon(0) returns total number of open server windows.
 
  var %x = $scon(0)
 
  ;  now we use while-loop to go through every open connections
 
  while (%x) {
 
    ; this changes the active connection for a script to connection id %x, so we can perform commands to other networks too
 
    scid $scon(%x)
 
    ; we need this variable to calculate later how long we were away
 
    set %awaytime $ctime
 
    ; this is where happens the actual happening, setting us away
 
    away %away.reason $since
 
    ; $chan(0) returns to total number of channels open in active network
 
    %awaychan = $chan(0)
 
    ; we use while-loop to go though every channel
 
    while (%awaychan) {
 
      ; echo means that only you can see the text we "echo", -t includes timestamp, $chan(%awaychan) returns to channel id
 
      ; $marked_away is our own made function.
 
      echo -t $chan(%awaychan) $marked_away
 
      dec %awaychan
 
    }
 
    ; we start timer what calls alias to create away timer in titlebar in every second
 
    ; alias downbelow
 
    .timerawaytime 0 1 titleawaytime
 
    ; echo -s echoes our awaymsg to statuswindow
 
    echo -st $marked_away
 
    dec %x
 
  }
 
 
  }
 
  }
  ; else, if we are in away mode
+
   
elseif ($away) {
+
alias away {
  ; %x - again, is number of open status windows
+
  ; if $away is $false (we are not away)
  var %x = $scon(0)
+
  [[If-Then-Else|if]] (!$away) {
  ; go through every status open connection with while-loop
+
    ;if $1 (word after function exists) we set [[Variables|variable]] %away.reason to value [[$1-]] (all words after alias)
  while (%x) {
+
    if ($1) { [[set]] %away.reason $1- }
    scid $scon(%x)
+
    ; else if there's no words after [[Aliases|alias]], se default reason to "Away"
    ; now because we are set away, we just use command "away" to set us back
+
    [[If-Then-Else|else]] { set %away.reason Away }
    away
+
    ; we need this variable later on in this alias in our self made function
    %awaychan = $chan(0)
+
    set %since_away $date $time
    while (%awaychan) {
+
    ; [[$scon]](0) returns total number of open server windows.
      echo -t $chan(%awaychan) $marked_back
+
    [[var]] %x = $scon(0)
      dec %awaychan
+
    ; [[While_loops|while-loop]] to go through every open connections
    }
+
    while (%x) {
    ; close timer we set to refresh away timer in titlebar every second
+
      ; this changes the active connection for a script to connection id %x
    .timerawaytime off
+
      ; so we can perform commands to other networks you're in too
    scid $scon(%x)
+
      scid $scon(%x)
    echo -st $marked_back
+
      ; we need this variable later to calculate how long we were away
    ; resets text in titlebar
+
      set %awaytime [[$ctime]]
    titlebar
+
      ; this is where happens the actual happening, setting us away
    dec %x
+
      [[away]] %away.reason $since
  }
+
      ; $chan(0) returns to total number of channels open in active network
 +
      %awaychan = [[$chan]](0)
 +
      ; we use while-loop to go though every channel
 +
      while (%awaychan) {
 +
        ; [[echo]] means that only you can see the text we "echo"
 +
        ; option -t includes timestamp, $chan(%awaychan) returns to channel id %awaychan
 +
        ; $marked_away is our own made function.
 +
        echo -t $chan(%awaychan) $marked_away
 +
        [[dec]] %awaychan
 +
      }
 +
      ; start timer what calls alias to create away timer in titlebar display it every second
 +
      .timerawaytime 0 1 titleawaytime
 +
      ; echo -s echoes our awaymsg to statuswindow
 +
      echo -st $marked_away
 +
      dec %x
 +
    }
 +
  }
 +
  ; else, if we are in away mode
 +
  [[If-Then-Else|elseif]] ($away) {
 +
    ; %x - again, is number of open status windows
 +
    var %x = $scon(0)
 +
    ; loop through every status open connection with while-loop
 +
    while (%x) {
 +
      scid $scon(%x)
 +
      ; now because we are set away, we just use command "away" to set us back
 +
      away
 +
      %awaychan = $chan(0)
 +
      while (%awaychan) {
 +
        echo -t $chan(%awaychan) $marked_back
 +
        dec %awaychan
 +
      }
 +
      ; close [[timer]] we set to refresh away timer in titlebar every second
 +
      .timerawaytime off
 +
      scid $scon(%x)
 +
      echo -st $marked_back
 +
      ; resets text in titlebar
 +
      [[titlebar]]
 +
      dec %x
 +
    }
 +
  }
 
  }
 
  }
}
+
 
+
; when we connect to any irc network, we start timer what does the trick with alias auto_away every 45's second
; when we connect to any irc network, we set timer what does alias auto_away every 45's second
+
on *:connect:{
on *:connect:{
+
  .timer 0 45 auto_away
.timer 0 45 auto_away
 
}
 
 
 
; -l in alias means that we can only call alias auto_away via another alias
 
alias -l auto_away {
 
; set %t how many secs we have to idle before setting away
 
var %t = 2700
 
; we check if have have idled %t seconds in every networks we are in
 
var %c = $scon(0)
 
while (%c) {
 
  scid $scon(%c)
 
  ; if we are not set away and we have idled over %t secs
 
  if (!$away) && ($idle > %t) {
 
    ; if variable %i doesnt exist, create one with value 1
 
    if (!%i) { var %i = 1 }
 
    ; else just increase it with one
 
    else { inc %i }
 
  }
 
  dec %c
 
 
  }
 
  }
  ; if %i has same valua as $scon(0) (number of networks)
+
   
if (%i == $scon(0)) {
+
; switch -l in alias means that alias can only be called via another alias
  set %since_away $date $time
+
alias -l auto_away {
  var %x = $scon(0)
+
  ; set %t how many secs we have to idle before setting away
  while (%x) {
+
  var %t = 2700
    scid $scon(%x)
+
  ; we check if have have idled %t seconds in every networks we are in
    set %awaytime $calc($ctime)
+
  var %c = $scon(0)
    set %away.reason Away after $duration(%t)
+
  while (%c) {
    !away %away.reason $since
+
    scid $scon(%c)
    %awaychan = $chan(0)
+
    ; if we are not set away and we have idled over %t secs
    while (%awaychan) {
+
    if (!$away) && ([[$idle]] > %t) {
      echo -t $chan(%awaychan) $marked_away
+
      ; if variable %i doesnt exist, create one with value 1
      dec %awaychan
+
      if (!%i) { var %i = 1 }
    }
+
      ; else just increase it with one
    .timerawaytime 0 1 titleawaytime
+
      else { inc %i }
    scid $scon(%x)
+
    }
    echo -st $marked_away
+
    dec %c
    dec %x
+
  }
  }
+
  ; if %i has same valua as $scon(0) (number of networks)
 +
  if (%i == $scon(0)) {
 +
    set %since_away $date $time
 +
    var %x = $scon(0)
 +
    while (%x) {
 +
      scid $scon(%x)
 +
      set %awaytime $calc($ctime)
 +
      set %away.reason Away after $duration(%t)
 +
      !away %away.reason $since
 +
      %awaychan = $chan(0)
 +
      while (%awaychan) {
 +
        echo -t $chan(%awaychan) $marked_away
 +
        dec %awaychan
 +
      }
 +
      .timerawaytime 0 1 titleawaytime
 +
      scid $scon(%x)
 +
      echo -st $marked_away
 +
      dec %x
 +
    }
 +
  }
 
  }
 
  }
}
+
 
+
; our own functions
 +
; $b(some text here) returns to bold text inside of function
 +
alias -l b [[return]] $+([[$chr]](2),$$1-,$chr(2))
 +
; calculates how many secs we have been away, called in titlebar included in /away -command
 +
alias -l titleawaytime titlebar AwayTime[ $+ [[$duration]]([[$calc]]($ctime - %awaytime)) $+ ]
 +
; sets time when we set away, gettok get only 2 first parametres from time, chr(58) is ":"
 +
; $remove get only day and month from [[$date]] and leaves year behind;)
 +
alias -l since return $+($b([),[[$gettok]]($time,1-2,58),´,$[[remove]]($date,$right($date,5)),$b(]))
 +
; next two aliases are lines what tells us how long we were away etc..
 +
alias -l marked_away return $+($chr(22),$b([[$str]]($chr(155),2))) You have been marked as being away. Reason $b([) $+ %away.reason $since $+ $b(]) $+ $chr(22)
 +
alias -l marked_back return $+($chr(22),$b($str($chr(155),2))) You are no longer marked as being away. You was gone for $b([) $+  $duration($calc($ctime - %awaytime)) $+ $b(]) - Since $b([) $+ %since_away $+ $b(]) - Reason - $b([) $+ %away.reason $+ $b(]) $+ chr(22)
  
; we create our own functions
+
[[Category:Tutorials]]
; $b(some text here) returns to bold text we put inside of function
 
alias -l b return $+($chr(2),$$1-,$chr(2))
 
; calculates how many secs we have been away, we called it to titlebar included in /away -command
 
alias -l titleawaytime titlebar AwayTime[ $+ $duration($calc($ctime - %awaytime)) $+ ]
 
; sets time when we set away, gettok get only 2 first parametres from time, chr(58) is ":"
 
; $remove get only day and month from $date and leaves year behind;)
 
alias -l since return $+($b([),$gettok($time,1-2,58),´,$remove($date,$right($date,5)),$b(]))
 
; next two aliases are lines what tells us how long we were away etc..
 
alias -l marked_away return $+($chr(22),$b($str($chr(155),2))) You have been marked as being away. Reason $b([) $+ %away.reason $since $+ $b(]) $+ $chr(22)
 
alias -l marked_back return $+($chr(22),$b($str($chr(155),2))) You are no longer marked as being away. You was gone for $b([) $+ $duration($calc($ctime - %awaytime)) $+ $b(]) - Since $b([) $+ %since_away $+ $b(]) - Reason - $b([) $+ %away.reason $+ $b(]) $+ $chr(22)</nowiki>
 
[[Category:Script Archive]]
 

Latest revision as of 13:43, 3 July 2007

This is an example of silent but a modified away script, including autoaway, away timer in titlebar and channel menus ($iif). Script checks if you away or not and sets you away/back. Applys to multiple networks you in (scid, $scon). We also get familar with our own made functions.

; this is an example of a silent but modified away script, including autoaway, away timer in titlebar and channel menus.
; script checks if you away or not and sets you away/back. Applys to multiple networks you in.
; we also get familar with our own made functions.

; halt default raws to that shows whenever you back/away in status window
raw 305:*:{ halt }
raw 306:*:{ halt }

; $iif(this is true,do this,else do this)
; $away returns $true whetner you've set away or $false
menu channel {
 $iif($away,Set Back,Set Away):{ $iif($away,away,away $?="Away Reason") }
}

alias away {
 ; if $away is $false (we are not away)
 if (!$away) {
   ;if $1 (word after function exists) we set variable %away.reason to value $1- (all words after alias)
   if ($1) { set %away.reason $1- }
   ; else if there's no words after alias, se default reason to "Away"
   else { set %away.reason Away }
   ; we need this variable later on in this alias in our self made function
   set %since_away $date $time
   ; $scon(0) returns total number of open server windows.
   var %x = $scon(0)
   ; while-loop to go through every open connections
   while (%x) {
     ; this changes the active connection for a script to connection id %x
     ; so we can perform commands to other networks you're in too
     scid $scon(%x)
     ; we need this variable later to calculate how long we were away
     set %awaytime $ctime
     ; this is where happens the actual happening, setting us away
     away %away.reason $since
     ; $chan(0) returns to total number of channels open in active network
     %awaychan = $chan(0)
     ; we use while-loop to go though every channel
     while (%awaychan) {
       ; echo means that only you can see the text we "echo"
       ; option -t includes timestamp, $chan(%awaychan) returns to channel id %awaychan
       ; $marked_away is our own made function.
       echo -t $chan(%awaychan) $marked_away
       dec %awaychan
     }
     ; start timer what calls alias to create away timer in titlebar display it every second
     .timerawaytime 0 1 titleawaytime
     ; echo -s echoes our awaymsg to statuswindow
     echo -st $marked_away
     dec %x
   }
 }
 ; else, if we are in away mode
 elseif ($away) {
   ; %x - again, is number of open status windows
   var %x = $scon(0)
   ; loop through every status open connection with while-loop
   while (%x) {
     scid $scon(%x)
     ; now because we are set away, we just use command "away" to set us back
     away
     %awaychan = $chan(0)
     while (%awaychan) {
       echo -t $chan(%awaychan) $marked_back
       dec %awaychan
     }
     ; close timer we set to refresh away timer in titlebar every second
     .timerawaytime off
     scid $scon(%x)
     echo -st $marked_back
     ; resets text in titlebar
     titlebar
     dec %x
   }
 }
}

; when we connect to any irc network, we start timer what does the trick with alias auto_away every 45's second
on *:connect:{
 .timer 0 45 auto_away
}

; switch -l in alias means that alias can only be called via another alias
alias -l auto_away {
 ; set %t how many secs we have to idle before setting away
 var %t = 2700
 ; we check if have have idled %t seconds in every networks we are in
 var %c = $scon(0)
 while (%c) {
   scid $scon(%c)
   ; if we are not set away and we have idled over %t secs
   if (!$away) && ($idle > %t) {
     ; if variable %i doesnt exist, create one with value 1
     if (!%i) { var %i = 1 }
     ; else just increase it with one
     else { inc %i }
   }
   dec %c
 }
 ; if %i has same valua as $scon(0) (number of networks)
 if (%i == $scon(0)) {
   set %since_away $date $time
   var %x = $scon(0)
   while (%x) {
     scid $scon(%x)
     set %awaytime $calc($ctime)
     set %away.reason Away after $duration(%t)
     !away %away.reason $since
     %awaychan = $chan(0)
     while (%awaychan) {
       echo -t $chan(%awaychan) $marked_away
       dec %awaychan
     }
     .timerawaytime 0 1 titleawaytime
     scid $scon(%x)
     echo -st $marked_away
     dec %x
   }
 }
}

; our own functions
; $b(some text here) returns to bold text inside of function
alias -l b return $+($chr(2),$$1-,$chr(2))
; calculates how many secs we have been away, called in titlebar included in /away -command
alias -l titleawaytime titlebar AwayTime[ $+ $duration($calc($ctime - %awaytime)) $+ ]
; sets time when we set away, gettok get only 2 first parametres from time, chr(58) is ":"
; $remove get only day and month from $date and leaves year behind;)
alias -l since return $+($b([),$gettok($time,1-2,58),´,$remove($date,$right($date,5)),$b(]))
; next two aliases are lines what tells us how long we were away etc..
alias -l marked_away return $+($chr(22),$b($str($chr(155),2))) You have been marked as being away. Reason $b([) $+ %away.reason $since $+ $b(]) $+ $chr(22)
alias -l marked_back return $+($chr(22),$b($str($chr(155),2))) You are no longer marked as being away. You was gone for $b([) $+  $duration($calc($ctime - %awaytime)) $+ $b(]) - Since $b([) $+ %since_away $+ $b(]) - Reason - $b([) $+ %away.reason $+ $b(]) $+ chr(22)