alias pmc1 {
  if ( %away.total.pages > 0 ) {
    echo -a $chr(35) of CTCP pages received: %away.total.pages $+ .
    set %away.total.pages 0
  }
  else echo -a CTCP ile ilgili herhangi bir komut gelmemiş.
}
alias repeataway {
  if (%away.rep) .timerblah 0 %away.rep. rep2 
}
alias rep2 {
  if (%away.rep. < 600) set %away.rep. 3600
  if ($chan(0)) ame is still away ( $+ %away.reason $+ ) ( $+ $a.cp $+ ) gone: $duration($calc($ctime - %away.time)) %savasreklam
  else return
}
alias cdate1 { return $date(dd/mmm/yy) : $time(HH:nn) }
alias away.logo { return %savasreklam }
alias sback {
  if ( $away == $true ) && ( %away.q.mode != on ) {
    Set %away.status off
    away
    if ( %away.nick == on ) {
      nick %away.oldnick
      unset %away.oldnick
      unset %away.newnick
      set %away.back $ctime
      .timerblah off
      if ( $chan(0) > 0 ) { ame Awaydan çıktım  ( $+ %away.reason $+ ) Away olduğum süre: $duration($calc(%away.back - %away.time)) %savasreklam }
      resetidle
      else { echo -a Artık away değilsin %away.reason $+ . Away kaldığın süre $duration($calc(%away.back - %away.time)) $+ . }
      unset %away.back
      unset %away.time
    }
    else {
      set %away.back $ctime
      if ( $chan(0) > 0 ) && (%away.time != $null) { ame is back ( $+ %away.reason $+ ) Gone: $duration($calc(%away.back - %away.time)) %savasreklam }
      else { echo -a Artık away değilsin %away.reason $+ . Away kaldığın süre $duration($calc($ctime - %away.back)) $+ . }
      resetidle
      aacheck
      .timerBlah on
      .unset %away.back
      .unset %away.time
      .unset %away.oldnick
      .unset %away.newnick
    }
  }
  elseif (%away.q.mode == on ) { qsback } 
  else Echo -a You're not away.
}
alias saway {
  if (%away.status == on) && ($away) echo -a  You're already away. 
  else {
    unset %away.reason
    set %away.reason $$?="Away Sebebi Yazınız?"
    away %away.reason
    repeataway
    set %away.time $ctime
    set %away.stamp $time
    set %away.q.mode off
    if ($chan(0)) { ame away oldum ( $+ %away.reason $+ ) $+ . ( $+ $a.cp $+ ) %savasreklam }
    else echo -a You are away. reason: %away.reason $+ . Pager %away.pager $+ . Log: %away.log $+ . 
    set %away.time $ctime
    awaycompare
  }
}
alias testpage {
  if ( %away.pager.wav == on ) && ( %away.pager.sound != empty ) splay %away.pager.sound
  else beep 10 100
}
alias qsaway {
  away %away.reason
  set %away.q.mode on
  unset %away.total.pages
  if ($1 != r) set %away.reason $$?="Away Sebebi Yazınız?"  
  set %away.status on
  set %away.time $ctime
  echo -a Pencere Durumu: %away.pager $+ . 
  echo -a Mesaj Log Durumu: %away.log $+ . 
  set %away.st.1 »» Away
  awaycompare
  echo -a Away Sebebin: %away.reason $+ .
}
alias qsback {
  if ($away) && ( %away.q.mode == on ) {
    set %away.back $ctime
    echo -a Artık away değilsin %away.reason $+ . Away kaldığın süre $duration($calc(%away.back - %away.time)) $+ .
    away
    if ( %away.nick == on ) {
      nick %away.oldnick
      unset %away.oldnick
      unset %away.newnick
    }
    pmc1
    set %away.q.mode off
    unset %away.time
    unset %away.back
  }
  else echo -a 5Buradan eski ayara dönülemiyor. Nereden away olduysanız oradan geri dönme seceneğini secin.
}
on *:start: { 
  if ($version < 5.6) || ($bits  != 32) { 
    echo 4Error:7 you must have mIRC ver. 5.6 or higher, and 32 bits version.
    echo Load canceled!
    halt
  }
  unset %away.total.pages
  if (%away.pager.clear == on) echo -a CTCP Pager log cleared. | write -c pager.log
  set %away.total.pages 0 
  if ( %predef.1 == $null ) set %predef.1 Empty
  if ( %predef.2 == $null ) set %predef.2 Empty
  if ( %predef.3 == $null ) set %predef.3 Empty
  if ( %predef.4 == $null ) set %predef.4 Empty
  if ( %predef.5 == $null ) set %predef.5 Empty
}
on *:load: {
  if ($version < 5.6) || ($bits  != 32) { 
    echo 4Error:7 To use Away System you must have mIRC ver. 5.6 or higher, and 32 bits version.
    echo Load canceled!
    halt
  }
  if ($away) { set %away.st.1 »» Away | set %away.status on }
  else { set %away.st.1 »» Not away | set %away.status off }
  set %away.nick on
  set %away.nick.1 {Away}
  unset %away.total.pages
  set -u0 %i 0
  :loop
  inc %i
  set %predef. $+ %i Empty
  if (%i < 5) goto loop
  set %away.pager on
  set %away.log on
  set %away.sc.a 
  set %away.sc.b 
  alias %away.sc.a maway
  alias %away.sc.b maway2
}
menu @Info {
  dclick:window -c @Info
}
alias awaycompare {
  if ( %away.nick == on ) && ( %away.nick.1 != $null ) {
    set %away.oldnick $me
    set %away.newnick $me $+ %away.nick.1
    nick %away.newnick
  }  
}
alias predefaway {
  unset %away.total.pages
  if ( %away.status == on ) && ( $away == $true ) echo -a  You're already away. 
  else {
    if ( %away.q.mode == on ) { set %away.q.mode off }
    away %away.reason
    set %away.status on
    set %away.st.1 »» Away
    if ($chan(0)) { ame is away - ( $+ %away.reason $+ ) $+ . ( $+ $cp $+ ) %savasreklam }
    else { echo -a You are away. reason: %away.reason $+ . Pager %away.pager $+ . Log: %away.log $+ . }
    set %away.time $ctime
    awaycompare
  }
}
alias idelest { if ( $idle > %auto.away.secs ) autoaway }
alias aacheck {
  if ( %auto.away == on ) {
    echo -a Auto-Away checker started.
    .timerIdling 0 1 idelest
  }
  ;  else halt
}
alias autoaway {
  .TimerIdling Off
  unset %away.total.pages
  if ($away) echo -a  You're already away. 
  else {
    .away %away.reason
    set %away.st.1 »» Away
    set %away.reason auto-away after $duration($idle)
    set %away.status on    
    .set %away.time $ctime
    .set %away.stamp $time
    set %away.oldnick $me  
    awaycompare
    if ($chan(0)) { ame is away - ( $+ %away.reason $+ ) $+ . ( $+ $a.cp $+ ) %savasreklam }
    else echo -a You are away - %away.reason $+ . 
  }
}
on *:connect: { aacheck }
; Track Messages
on *:text:*:?: {
  if ($away) && ( %away.log == on ) {
    msg $nick  14Su anda yokum, eger bir mesajin varsa birak gelince okurum..! %savasreklam
    write logs\msg.log $timestamp $nick  $1-
    closemsg $nick
  }
}
alias maway {
  if ($away) sback
  else saway
}
alias maway2 { ; if $1 == r there is a reason, we don't need to request it from the user!
  if ($away) qsback
  else qsaway $1-
}
ctcp *:PAGE:*: {
  if ($away) && ( %away.pager == on ) {
    haltdef
    write logs\pager.log Page received at $cdate $+ , from $nick $+ . message: $$2-
    echo -a logs\Page from $nick $+ : $$2-
    inc %away.total.pages
    testpage
  }
  else return
}
alias ANOn {
  set %away.nick on 
  echo -a Away nick enabled 
  set %away.nick.1 $$?="Enter away nick - e.g. : -gone, -away, {A}"
  if ( %away.nick.1 == $null ) { set %away.nick.1 {Away} }
  else echo -a Away nickname set to %away.nick.1 $+ .
  if ($away) nick %away.nick.1
}
Alias ANOff set %away.nick off | echo -a Away nick disabled

menu menubar,channel,status {
  Away Sistemi
  .Away Systemi K&ontrol Paneli : open.AwaySysDialog
  .&Away ol / geri dön
  ..&Set Away/Geri dön:maway2
  .&Genele (/ame)
  ..&Away ol/Geri dön:maway
  ..&Away Sebebi Sec
  ...&Yemek:if ($away == $false) set %away.reason Yemekteyim | predefaway
  ...&Uyku:if ($away == $false) set %away.reason Su an uyuyorum. Ses yapmayin. | predefaway
  ...&Web:if ($away == $false) set %away.reason Su an web sayfalarinda sorf yapiyorum | predefaway
  ...&Gezinti:if ($away == $false) set %away.reason Dışardayım, geziyorum.. | predefaway
  ...&Sigara:if ($away == $false) set %away.reason Sigara icmekteyim. | predefaway
  ...&Kahve:if ($away == $false) set %away.reason Kahve iciyorum, istermisin ? | predefaway
  ...&Customized
  ....1 ( $+ %predef.1 $+ )
  .....Use this one:if (%predef.1 != empty) && ($away == $false) set %away.reason %predef.1 | predefaway
  .....Change...:set %predef.1 $$?="Enter reason: "
  ....2 ( $+ %predef.2 $+ )
  .....Use this one:if ( %predef.2 != empty ) && if ($away == $false) set %away.reason %predef.2 | predefaway
  .....Change...:set %predef.2 $$?="Enter reason: "
  ....3 ( $+ %predef.3 $+ )
  .....Use this one:if ( %predef.3 != empty ) && if ($away == $false) set %away.reason %predef.3 | predefaway
  .....Change...:set %predef.3 $$?="Enter reason: "
  ....4 ( $+ %predef.4 $+ )
  .....Use this one:if ( %predef.4 != empty ) && if ($away == $false) set %away.reason %predef.4 | predefaway
  .....Change...:set %predef.4 $$?="Enter reason: "
  ....5 ( $+ %predef.5 $+ )
  .....Use this one:if ( %predef.5 != empty ) && if ($away == $false) set %away.reason %predef.5 | predefaway
  .....Change...:set %predef.5 $$?="Enter reason: "
  .&Away Nick
  ..$iif(%away.nick == on,off,on):if (%away.nick == on) anoff | else anon

  ..&Set away nick: {
    set %away.nick.1 $$?="Enter away nick - e.g. : -gone, -away, {A}"
    if ( %away.nick.1 == $null ) { set %away.nick.1 -Gone }
    else echo -a Away nickname set to %away.nick.1 $+ .
  }
}

; ##############
; # Dialog Section    #
; ##############

alias open.AwaySysDialog {
  if ($dialog(AwaySysDialog) != $null)  { dialog -v AwaySysDialog AwaySysDialog }
  else { dialog -m AwaySysDialog AwaySysDialog }  
}

Dialog AwaySysDialog {
  title "«« x1»» Away Paneli"
  size -1 -1 390 285
  box "Away ayarları", 1, 10 10 370 235
  text "&Nickim:", 2, 20 30 63 15
  radio "Away" ,3, 110 30 45 15, group
  radio "Away değil" ,4, 181 30 70 15
  text "&Away Olduğunda:" ,5, 20 50 85 15
  radio "Sessiz Kal" , 6, 110 50 66 15, group
  radio "Tüm Kanallara Sebeb Bildir" ,7, 181 50 185 15
  text "&Away Sebebi:", 40, 20 72 102 15
  combo 8, 139 70 120 150 , edit drop
  text "&Nickine away eki getir:" ,9, 20 95 130 15
  radio "Evet", 10, 155 95 47 15, group
  radio "Hayır", 11, 197 95 45 15
  text "A&way ekini seç:", 12, 20 117 114 15
  combo 13, 139 113 120 90 , edit drop
  text "&Mesaj:", 14, 20 145 30 15
  radio "On", 15, 78 145 33 15, group
  radio "Off", 16, 116 145 45 15
  button "&Logları gör", 17, 155 140 90 20, flat
  button "L&ogları sil", 18, 255 140 90 20, flat
  button "!", 19.1, 355 140 15 20, flat
  text "Lo&g:", 49, 20 170 20 15
  radio "On", 20, 78 170 33 15, group
  radio "Off", 21, 116 170 45 15
  button "L&ogları gör", 22, 155 165 90 20, flat
  button "L&ogları sil", 23, 255 165 90 20, flat
  text "Otomatik awa&y:", 24, 20 195 53 15
  radio "On", 25, 78 195 33 15, group
  radio "Off", 26, 116 195 45 15
  button "&Kaç saniye", 27, 155 190 90 20, flat
  text "F Tuslarini Kullan:", 28, 20 220 100 15
  text "Away (/a&me):", 29, 125 220 63 15
  edit "", 30, 193 217 30 20
  text "Away (&Quiet):", 31, 228 220 63 15
  edit "", 32, 296 217 30 20
  button "&Evet", 35, 50 255 90 25, ok flat
  button "&Vazgeç", 36, 150 255 90 25, cancel flat
}

on 1:dialog:AwaySysDialog:init:0: {
  ;if (%away.st.1 == »» Not away) did -cf AwaySysDialog 4
  ;else { did -cf AwaySysDialog 3 }
  if ($away) { did -cf AwaySysDialog 3 | set %away.st.1 »» Away | set %away.status on }
  else { did -cf AwaySysDialog 4 | set %away.st.1 »» Not away | set %away.status off }
  if (%away.nick == on) did -c AwaySysDialog 10
  else { did -c AwaySysDialog 11 | did -b AwaySysDialog 12,13 }
  if (%away.pager == on) did -c AwaySysDialog 15
  else did -c AwaySysDialog 16
  if (%away.log == on) did -c AwaySysDialog 20
  else did -c AwaySysDialog 21
  did -c AwaySysDialog 7
  if (%auto.away == on) did -c AwaySysDialog 25
  else did -c AwaySysDialog 26
  did -a AwaySysDialog 30 %away.sc.a
  did -a AwaySysDialog 32 %away.sc.b
  if (%away.nick.1 != $null) { did -a AwaySysDialog 13 %away.nick.1 }
  if (%away.nick.1 != {Away} ) did -a AwaySysDialog 13 {Away}
  if (%away.nick.1 != -Yok ) did -a AwaySysDialog 13 -Yok
  if (%away.nick.1 != -away ) did -a AwaySysDialog 13 -away
  did -c AwaySysDialog 13 1
  did -a AwaySysDialog 8 Yemek
  did -a AwaySysDialog 8 Uyku
  did -a AwaySysDialog 8 Web Gezintisi
  did -a AwaySysDialog 8 Dışardayım
  did -a AwaySysDialog 8 Sigara Molası
  did -a AwaySysDialog 8 Cafe Molası
  if (%predef.1 != Empty) did -a AwaySysDialog 8 %predef.1
  if (%predef.2 != Empty) did -a AwaySysDialog 8 %predef.2
  if (%predef.3 != Empty) did -a AwaySysDialog 8 %predef.3
  if (%predef.4 != Empty) did -a AwaySysDialog 8 %predef.4
  if (%predef.5 != Empty) did -a AwaySysDialog 8 %predef.5  
}

on 1:dialog:AwaySysDialog:sclick:35: {
  ; add the reason to the list if there is an empty place and it not of the default reasons
  if ($did(8) == $null) goto continue
  if ($did(8) == food) || ($did(8) == sleep-zzz) || ($did(8) == Surfin' the Web) || ($did(8) == Went outside) || ($did(8) == Out 4 a smoke) || ($did(8) == Coffee break) { goto continue }
  if (($did(8) == %predef.1) || ($did(8) == %predef.2) || ($did(8) == %predef.3) || ($did(8) == %predef.4) || ($did(8) == %predef.5)) && $did(8) != Empty { goto continue }
  if ($did(8) == Empty) { goto continue }
  if (%predef.1 == Empty) { set %predef.1 $did(8) | goto continue }
  if (%predef.2 == Empty) { set %predef.2 $did(8) | goto continue }
  if (%predef.3 == Empty) { set %predef.3 $did(8) | goto continue }
  if (%predef.4 == Empty) { set %predef.4 $did(8) | goto continue }
  if (%predef.5 == Empty) { set %predef.5 $did(8) | goto continue }
  :continue
  ; auto away
  if ($did(25).state == 1) set %auto.away on
  else set %auto.away off
  ; pager
  if ($did(15).state == 1) set %away.pager on
  else set %away.pager off
  ; log
  if ($did(20).state == 1) set %away.log on
  else set %away.log off
  ; shortcut keys
  if ($did(30) != %away.sc.a) {
    alias %away.sc.a
    set %away.sc.a $did(30)
    alias %away.sc.a maway
  }
  if ($did(32) != %away.sc.b) {
    alias %away.sc.b
    set %away.sc.b $did(32)
    alias %away.sc.b maway2
  }
  ; use away nick
  if ($did(13) == $null) set %away.nick.1 {Away}
  set %away.nick.1 $did(13)
  if ($did(10).state == 1) {
    set %away.nick on    
  }
  else set %away.nick off
  ; Going away now
  if ($did(3).state == 1 && %away.status == off) {
    if ($did(6).state == 1) { 
      if ($did(8) == $null) set %away.reason No reason
      else set %away.reason $did(8)
      maway2 r   ; don't delete the 'r'!!
    }
    else {
      if ($did(8) == $null) set %away.reason No reason
      else set %away.reason $did(8)
      predefaway
    }
  }
  ; Back now
  if ($did(4).state == 1 && %away.status == on) {
    if (did(6).state == 1) maway2
    else maway
  }
}
on 1:dialog:AwaySysDialog:sclick:11: {
  did -b AwaySysDialog 12,13
}

on 1:dialog:AwaySysDialog:sclick:10: {
  did -e AwaySysDialog 12,13
}

on 1:dialog:AwaySysDialog:sclick:26: {
  did -b AwaySysDialog 27
}

on 1:dialog:AwaySysDialog:sclick:25: {
  did -e AwaySysDialog 27
}
on 1:dialog:AwaySysDialog:sclick:17: {
  window -ak @PagerLog -0 -0 
  if ( $exists(logs\pager.log)) { loadbuf @PagerLog logs\pager.log } 
  else {
    write logs\pager.log $away.logo
    loadbuf @PagerLog logs\pager.log
  }
}
alias ClearPagerLog {
  if ( $$?!="Loglar Silinsinmi?" == $true ) { write -c logs\pager.log | write logs\pager.log $away.logo | echo -a CTCP pager log cleared. }
}
on 1:dialog:AwaySysDialog:sclick:18: .timer 1 0 ClearPagerLog
on 1:dialog:AwaySysDialog:sclick:22: {
  window -ak @MSGLog -0 -0
  if ( $exists(logs\msg.log)) { loadbuf @MSGLog logs\msg.log }
  else {
    write logs\msg.log $away.logo
    loadbuf @MSGLog logs\msg.log
  }
}
alias ClearMsgLog {
  if ( $$?!="Loglar Silinsinmi?" == $true ) { write -c logs\msg.log | write logs\msg.log $away.logo | echo -a MSG Log cleared. } | else halt
}
on 1:dialog:AwaySysDialog:sclick:23: .timer 1 0 ClearMsgLog
alias SetTime {
  set %auto.away.etp $$?="Enter number of seconds:"
  if (%auto.away.etp isnum ) && ( %auto.away.etp > 0 ) set %auto.away.secs %auto.away.etp | Echo -a Auto away set to %auto.away.etp seconds. | .unset %auto.away.etp  | aacheck
}
on 1:dialog:AwaySysDialog:sclick:27: .timer 1 0 SetTime
alias SetPagerSound {
  set %away.pager.wav on
  if ( $$?!="Would you like to use a WAV file for the pager sound?" == $true ) set %away.pager.sound $dir[="Choose WAV file to play when Pager comes"] *.wav
  else { set %away.pager.sound empty | set %away.pager.wav off }
}
on 1:dialog:AwaySysDialog:sclick:19: .timer 1 0 SetPagerSound
on 1:dialog:AwaySysDialog:sclick:37: .about

alias a.cp {
  if (%away.pager == on) && (%away.log == on) return +pl
  elseif (%away.pager == on) && (%away.log == off) return +p
  elseif (%away.pager == off) && (%away.log == off) return -pl
  elseif (%away.pager == off) && (%away.log == on) return +l
}
