Difference between revisions of "Modifying mIRCs own Away system"
From Scriptwiki
BlackShroud (talk | contribs) |
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. | ||
− | + | ; 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 | + | ; [[$away]] returns $true whetner you've set away or $false |
− | + | menu channel { | |
− | menu channel { | + | $iif($away,Set Back,Set Away):{ $iif($away,away,away $?="Away Reason") } |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | ; else, if we are in away mode | + | |
− | + | alias away { | |
− | + | ; if $away is $false (we are not away) | |
− | + | [[If-Then-Else|if]] (!$away) { | |
− | + | ;if $1 (word after function exists) we set [[Variables|variable]] %away.reason to value [[$1-]] (all words after alias) | |
− | + | if ($1) { [[set]] %away.reason $1- } | |
− | + | ; else if there's no words after [[Aliases|alias]], se default reason to "Away" | |
− | + | [[If-Then-Else|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_loops|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 | ||
+ | [[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 | + | on *:connect:{ |
− | on *:connect:{ | + | .timer 0 45 auto_away |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | ; if %i has same valua as $scon(0) (number of networks) | + | |
− | + | ; 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) | ||
− | + | [[Category:Tutorials]] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | [[Category: |
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)