rendered paste body
}
dec %x
while (%x < 7) {
inc %x
if ($readini(AwaySettings.ini,presets,%x)) remini AwaySettings.ini Presets %x
}
}
; ----- Save Idle away settings
on *:dialog:Idle.Away.Settings:close:*: {
writeini AwaySettings.ini Config IdleSettings $+($did(3).seltext,~,$iif($did(4),$ifmatch,IDLE),~,$iif($did(6),$ifmatch,Auto away after % $+ time minutes idle))
}
; ----- Save Preset settings
on *:dialog:Away.Preset:close:*: {
var %pre = %away.EditPreset
if (!$did(3)) var %x = $input(Error: No trigger was specified,ow,Input Error)
elseif (!$did(6)) && ($did(5).seltext != Don't Change) var %x = $input(Error: You did not specify $iif($did(5).seltext,a nick $iif($did(5).seltext == set to,to change to,$ifmatch),any nick settings),ow,Input Error)
elseif ($remove($did(6),$chr(91),$chr(93),$chr(92),$chr(45),$chr(95),$chr(123),$chr(124),$chr(125)) !isalnum) && ($did(6)) { var %x = $input(Error: Invalid Characters detected in specified nick,wo,Input Error) | halt }
elseif (!$did(5).seltext) var %x = $input(Error: You have not specified how to change your nick - Select an option from the nick settings drop down,ow,Error)
elseif ($numtok($did(3),32) > 1) || ($numtok($did(6),32) > 1) var %x = $input(Error: Trigger and nick Settings can each only be one word long,wo,Input Error)
else {
did $iif(%pre,-o,-a) Custom.Aways 5 $iif(%pre,%pre) $did(3)
did $iif(%pre,-o,-a) Custom.Aways 6 $iif(%pre,%pre) $did(5).seltext $+ $iif($did(5).seltext != Don't Change,: $did(6))
did $iif(%pre,-o,-a) Custom.Aways 7 $iif(%pre,%pre) $did(hot.PNG
unset %away.EditPreset
}
}
; ---- Save Exception settings
on *:dialog:Away.AddException:close:*: {
if (!$did(3)) var %x = $input(No Network name was entered,wo,Input Error)
elseif ($numtok($did(3),32) > 1) var %x = $input(Network name may not contain spaces,wo,Input Error)
else {
var %scope = $iif($did(6).state == 1,1,2)
var %x = 1, %numchans = $numtok($did(9),32)
while (%x <= %numchans) {
var %token = $gettok($did(9),%x,32)
if (#?* iswm %token) var %chans = %chans %token
elseif (%token != $chr(35)) var %chans = %chans $+($chr(35),%token)
inc %x
}
var %x = 12
while (%x <= 15) {
var %options = %options $+ $did(%x).state
inc %x
}
did $iif(%Away.ExceptionNum,-o,-a) Away.Exceptions 3 $iif(%Away.ExceptionNum,$ifmatch) $did(3)
writeini AwaySettings.ini Exceptions $did(3) $+(%scope,~,%options,~,%chans)
unset %Away.Exception*
}
}
; ##############################################
; # /Away And /back aliases #
; ##############################################
alias away {
; ----- Unset Idle timer, Get highlights, enable #away group for logging etc
if ($timer(Away.IdleCheck)) .timerAway.IdleCheck off
set %Away.Hilights $readini(awaySettings.ini,n,Config,Hilights)
.enable #away
; ---- Retrieve away settings from config/User entry
var %time = $calc($readini(AwaySettings.ini,Config,AutoAwayTime) / 60)
if ($1) set %away.Reason $1-
elseif ($readini(AwaySettings.ini,Config,DefaultMessage)) set %away.Reason $v1
set %Away.LeftAt $ctime
if ($readini(AwaySettings.ini,Config,LeavingTime) == on) {
var %LeavingTimeFormat = $readini(AwaySettings.ini,Config,LeavingTimeFormat)
set %away.LeaveTime $time(%LeavingTimeFormat)
}
; ---- Check for idleaway
If ($1- = Auto.Idle.Away) {
var %IdleInfo = $readini(AwaySettings.ini,Config,IdleSettings)
var %edittype = $gettok(%IdleInfo,1,126)
if (%edittype == Set to) var %nickset = $gettok(%IdleInfo,2,126)
else var %nickadd = $gettok(%IdleInfo,2,126)
set %Away.Reason $($gettok(%IdleInfo,3-,126),2)
}
else {
var %edittype = $readini(AwaySettings.ini,Config,NickEditType)
if (%edittype == Set To) var %nickset = $readini(AwaySettings.ini,Config,NickSetTo)
else var %nickadd = $readini(AwaySettings.ini,Config,Nick $+ %edittype)
}
; ----- Check for presets
var %x 1
while (%x <= 7) {
if ($readini(AwaySettings.ini,Presets,%x)) {
var %preset = $v1
if ($1- == $gettok(%preset,1,126)) {
var %edittype = $gettok($gettok(%preset,2,126),1,58)
var %nickadd = $remove($gettok($gettok(%preset,2,126),2,58),$chr(32))
set %Away.Reason $gettok(%preset,3-,126)
set %Away.Preset %x
var %x = 7
}
}
inc %x
}
; ----- Cycle Connections to change nick/send msg
var %x = 1, %connections = $scon(0)
while (%x <= %connections) {
scon %x
if ($status == connected) {
unset %Except.*
if ($readini(AwaySettings.ini,Exceptions,$network)) {
var %Except.info = $v1
var %Except.Scope = $gettok(%Except.info,1,126)
var %Except.Options = $gettok(%Except.info,2,126)
if (%Except.Scope == 2) && ($mid(%Except.Options,2,1) == 1) var %Except.NoMsgChans = $gettok(%Except.Info,3-,126)
if (%Except.Scope == 1) && ($left(%Except.Options,1) == 1) var %Except.NoNickChange = 1
if (%Except.Scope == 1) && ($mid(%Except.Options,2,1) == 1) var %Except.NoAwayMsg = 1
}
set $+(%,Away.Oldnick.,$network) $me
if ($readini(AwaySettings.ini,Config,NickEditType) != Don't Change) && (!%Except.NoNickChange) {
if (%edittype == Set To) && (%NickSet != $me) var %newnick = %NickSet
if (%edittype == Prefix) && ($+(%nickadd,*) !iswm $me) var %newnick = $+(%nickadd,$me)
if (%edittype == Suffix) && ($+(*,%nickadd) !iswm $me) var %newnick = $+($me,%nickadd)
set $+(%,Away.Newnick.,$network) $iif(%newnick,$ifmatch,$me)
if (%newnick) nick %newnick
}
if ($chan(0)) && ($readini(AwaySettings.ini,Config,MsgChans) == on) && (!%Except.NoAwayMsg) {
var %Chan = 1, %TotalChans = $chan(0)
while (%chan <= %TotalChans) {
if (!$istok(%Except.NoMsgChans,$chan(%chan),32)) describe $chan(%chan) is now away $iif(%Away.Reason,- %Away.Reason) $iif(%Away.leavetime,- Left at %Away.Leavetime)
inc %chan
}
}
if ($readini(AwaySettings.ini,Config,MsgQueries) == on) && (!%Except.NoAwayMsg) {
qme is now away $iif(%Away.Reason,- %Away.Reason) $iif(%Away.leavetime,- Left at %Away.Leavetime)
}
!away Away: $iif(%Away.Reason,- %Away.Reason) $iif(%Away.leavetime,- Left at %Away.Leavetime)
}
inc %x
}
}
alias back {
var %x = 1, %connections = $scon(0)
while (%x <= %connections) {
scon %x
if ($status == connected) {
unset %Except.*
if ($readini(AwaySettings.ini,Exceptions,$network)) {
var %Except.info = $v1
var %Except.Scope = $gettok(%Except.info,1,126)
var %Except.Options = $gettok(%Except.info,2,126)
if (%Except.Scope == 2) && ($mid(%Except.Options,2,1) == 1) var %Except.NoMsgChans = $gettok(%Except.Info,3-,126)
if (%Except.Scope == 1) && ($left(%Except.Options,1) == 1) var %Except.NoNickChange = 1
if (%Except.Scope == 1) && ($mid(%Except.Options,2,1) == 1) var %Except.NoAwayMsg = 1
}
if (!%Except.NoNickChange) && ($($+(%,Away.Oldnick.,$network),2)) nick $ifmatch
; ----- Cycle Connections to change nick/send msg
if ($chan(0)) && ($readini(AwaySettings.ini,Config,MsgChans) == on) && (!%Except.NoAwayMsg) {
var %Chan = 1, %TotalChans = $chan(0)
while (%chan <= %TotalChans) {
if (!$istok(%Except.NoMsgChans,$chan(%chan),32)) describe $chan(%chan) is back $iif(%away.Reason,- from %Away.Reason) $iif(%Away.Leavetime,- Left at %Away.Leavetime) $iif($Away.GoneFor,- Gone for $Away.GoneFor)
inc %chan
}
}
if ($readini(AwaySettings.ini,Config,MsgQueries) == on) && (!%Except.NoAwayMsg) {
qme is now away $iif(%Away.Reason,- %Away.Reason) $iif(%Away.leavetime,- Left at %Away.Leavetime)
}
!away
}
inc %x
}
.disable #away
unset %away.*
if ($hget(Away.PM.Responses)) || ($hget(Away.Highlight.Responses)) hfree -w Away.*.Responses
if ($readini(AwaySettings.ini,Config,AutoAway) == on) .timerAway.IdleCheck -o 0 30 Away.IdleCheck
}
; ##############################################
; # Other Aliases #
; ##############################################
alias -l Away.Gonefor {
if ($readini(AwaySettings.ini,Config,TimeAway) == on) {
var %TimeAwayFormat = $readini(AwaySettings.ini,Config,TimeAwayFormat)
if (%Away.LeftAt) {
var %duration = $duration($calc($ctime - %Away.LeftAt),%TimeAwayFormat)
if (%TimeAwayFormat == Short) return $Short.Duration(%duration)
elseif (%TimeAwayFormat == medium) return %duration
elseif (%TimeAwayFormat == long) return $Long.Duration(%duration)
}
}
else return $false
}
alias -l Short.Duration return $replacex($1-,secs,s,sec,s,mins,m,min,m,hrs,h,hr,h,days,d,day,d,wks,w,wk,w)
alias -l Long.Duration return $replacex($1-,sec,second,secs,seconds,min,minute,mins,minutes,hr,hour,hrs,hours,wk,week,wks,w
eeks)
alias -l Get.Highlights {
var %x = 1, %Groups = $ini(mirc.ini,highlight,0)
while (%x <= %groups) {
var %Away.Highlights = $addtok(%Away.highlights,$highlight(%x),44)
inc %x
}
return %Away.Highlights
}
alias -l Check.For.highlights {
if (!%Away.Highlights) set %Away.Highlights $readini(AwaySettings.ini,n,Config,Hilights)
var %x = 1, %highlights = $numtok(%Away.highlights,44)
while (%x <= %highlights) {
var %chighlight = $($gettok(%Away.Highlights,%x,44),2)
if ($istok($1-,%chighlight,32)) return %chighlight
inc %x
}
return $false
}
alias -l Away.Logwin {
if (!$window(@Away.Logs)) window -eknz @Away.Logs
echo -ti2 @Away.Logs $1-
}
alias -l Highlight.Response {
if (!$hget(Away.highlight.Responses,$+($1,.,$2))) {
scid $1 .notice $2 I am currently away $iif(%Away.Reason,- %Away.Reason) $iif(%Away.LeaveTime,- Left at %Away.LeaveTime) $iif($away.gonefor,- Gone for $away.gonefor) - One time response to highlight
hadd -m Away.Highlight.Responses $+($1,.,$2) 1
}
}
alias -l Private.Message.Response {
if (!$hget(Away.PM.Responses,$+($1,.,$2))) {
scid $1 .notice $2 I am currently away $iif(%Away.Reason,- %Away.Reason) $iif(%Away.LeaveTime,- Left at %Away.LeaveTime) $iif($away.gonefor,- Gone for $away.gonefor) - One time response to Private Message
hadd -m Away.PM.Responses $+($1,.,$2) 1
}
}
alias -l Away.IdleCheck {
var %x = 1, %networks = $scon(0)
var %AutoAwayTime = $readini(AwaySettings.ini,Config,AutoAwayTime)
while (%x <= %networks) {
scon %x {
if ($status == Connected) && ($idle < %AutoAwayTime) var %Idle = off
}
inc %x
}
if (%idle != off) away Auto.Idle.Away
}
alias Away.Config dialog $iif($dialog(Away),-v,-m) Away Away
; ##############################################
; # Logging and hilight resposes #
; ##############################################
#away off
;Hilight responses
on *:text:*:#: {
if (!$Check.For.highlights($1-)) && (!$istok($1-,$me,32)) && (!$istok($1-,$($+(%,Away.Oldnick.,$network),2),32)) return
else {
Away.Logwin 4[10CHANNEL MESSAGE4] $+(4[10,$iif($scon(0) > 1,$+($network,12/10)),$chan,12/10,$nick,4]) $1-
if ($readini(AwaySettings.ini,Exceptions,$network)) {
var -s %Except.info = $v1
var -s %Except.Scope = $gettok(%Except.info,1,126), %Except.Options = $gettok(%Except.info,2,126)
if (%Except.Scope == 2) && ($mid(%Except.Options,3,1) == 1) var %Except.NoHilight = $gettok(%Except.Info,3-,126)
elseif (%Except.Scope == 1) && ($mid(%Except.Options,3,1) == 1) return
}
if (!$istok(%Except.NoHilight,$chan,32)) && ($readini(AwaySettings.ini,Config,RespondHilights) == on) Highlight.Response $cid $nick
}
}
on *:action:*:#: {
if (!$check.for.highlights($1-)) && (!$istok($1-,$me,32)) && (!$istok($1-,$($+(%,Away.Oldnick.,$network),2),32)) return
else {
Away.Logwin 4[10CHANNEL 10ACTION4] $+(4[10,$iif($scon(0) > 1,$+($network,12/10)),$chan,12/10,$nick,4]) * $nick $1-
if ($readini(AwaySettings.ini,Exceptions,$network)) {
var %Except.info = $v1
var %Except.Scope = $gettok(%Except.info,1,126), %Except.Options = $gettok(%Except.info,2,126)
if (%Except.Scope == 2) && ($mid(%Except.Options,3,1) == 1) var %Except.NoHilight = $gettok(%Except.Info,3-,126)
elseif (%Except.Scope == 1) && ($mid(%Except.Options,3,1) == 1) return
}
if (!$istok(%Except.NoHilight,$chan,32)) && ($readini(AwaySettings.ini,Config,RespondHilights) == on) Highlight.Response $cid $nick
}
}
; Private notice response
on *:notice:*:?: {
if (*serv !iswm $nick) {
Away.Logwin 4[10PRIVATE NOTICE4] $+(4[10,$iif($scon(0) > 1,$+($network,12/10)),Private,12/10,$nick,4]) $1-
if ($readini(AwaySettings.ini,Exceptions,$network)) {
var %Except.info = $v1
var %Except.Scope = $gettok(%Except.info,1,126), %Except.Options = $gettok(%Except.info,2,126)
if (%Except.Scope == 1) && ($right(%Except.Options,1) == 1) return
}
if ($readini(AwaySettings.ini,Config,RespondNotice) == on) Private.Message.Response $cid $nick
}
}
;PM responses
on *:text:*:?: {
if ($readini(AwaySettings.ini,Config,RespondPM) == on) && (*serv !iswm $nick) {
if ($readini(AwaySettings.ini,Exceptions,$network)) {
var %Except.info = $v1
var %Except.Scope = $gettok(%Except.info,1,126), %Except.Options = $gettok(%Except.info,2,126)
if (%Except.Scope == 2) && ($mid(%Except.Options,3,1) == 1) var %Except.NoHilight = $gettok(%Except.Info,3-,126)
elseif (%Except.Scope == 1) && ($right(%Except.Options,1) == 1) return
}
Private.Message.Response $cid $nick
}
}
;Return from away on input if set
on *:input:#: {
if ($left($1,1) != $readini(mirc.ini,text,commandchar)) {
if ($readini(AwaySettings.ini,Config,ARChannelMessage) == on) back
}
}
on *:input:?: {
if ($left($1,1) != $readini(mirc.ini,text,commandchar)) {
if ($readini(AwaySettings.ini,Config,ARPrivateMessage) == on) back
}
}
#away end