Modifying mIRCs own Away system
From Scriptwiki
Revision as of 14:59, 23 August 2005 by BlackShroud (talk | contribs)
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 to $true and $false, we check if if it's true (we are away) -> displays in channel menu "Set Back" ; and if $away is $false (we are not away) -> channel menu displays "Set Away" 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 %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) { ; %x - again, is number of open status windows var %x = $scon(0) ; go 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 set timer what does alias auto_away every 45's second on *:connect:{ .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)) { 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 } } } ; we create our own functions ; $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)