Alarm Clock

By smilinbob on Sep 16, 2010

Screenshots

This is an alarm clock I created using dialogs.
You can specify duration alarms (go off in 5 minutes) or time alarms (go off at 2:00). Snooze function is also supported, and includes a limiter. Multiple alarms may be activated, and may go off at the same time.

The active alarms dialog gives you information on alarms created with this script.

"Alarms" menu is added to pop-ups in channel and status windows. There are 2 options;
New Alarm: Opens the new alarm dialog
Active Alarms: Opens the active alarms dialog

ON *:dialog:alarm*:sclick:*: {
  if ($did == 2) {
    var %sn = $left($gettok($did(2),2,40),-1)
    dec %sn
    if ($did(3) isnum) && ($did(4) isnum) && ($did(5) isnum) {
      var %t = $duration($did(3) $+ : $+ $did(4) $+ : $+ $did(5))
      .timer 1 %t /alarm $did(10) $+ $chr(131) $+ %sn $+ $chr(131) $+ $did(1)
      echo 11 -e $timestamp " $+ $did(1) $+ " Alarm suspended: $duration(%t)
    }
  }
  elseif ($did == 9 ) {
    echo 11 -e $timestamp " $+ $did(1) $+ " Alarm dismissed.
  }
}
ON *:dialog:alarm*:close:*: {
  .timeralrm off  
  splay stop
}
ON *:dialog:new:sclick:*: {
  if ($did(20).state == 1) { var %s = 1 }
  elseif ($did(21).state == 1) { var %s = 0 }
  elseif ($did(22).state == 1) {
    if ($did(23) == $null) { 
      var %s = 0 
    }
    else {
      var %s = $did(23)
    }
  }
  if ($did == 2) && ($did(3) isnum) && ($did(4) isnum) && ($did(5) isnum) && ($did(17) isnum) && ($did(1)) {
    var %t = $duration($did(3) $+ : $+ $did(4) $+ : $+ $did(5))
    .timer 1 %t /alarm %s $+ $chr(131) $+ $iif($did(15).state,$did(17),0) $+ $chr(131) $+ $did(1)
    echo 11 -e $timestamp " $+ $did(1) $+ " Alarm created. Duration $duration(%t) Sound = %s
    dialog -x new
  }
  elseif ($did == 14) && ($did(17) isnum) && ($numtok($did(new,12),58) == 2) && ($gettok($did(new,12),1,58) isnum 0-23) && ($gettok($did(new,12),2,58) isnum 0-59) && ($did(1)) {
    .timer $did(12) 1 0 /alarm %s $+ $chr(131) $+ $iif($did(15).state,$did(17),0) $+ $chr(131) $+ $did(1)
    echo 11 -e $timestamp " $+ $did(1) $+ " Alarm created. Time: $did(12) 
    dialog -x new    
  }
  elseif ($did == 15) {
    if ($did(15).state == 0) {
      did -b new 17
    }
    elseif ($did(15).state == 1) {
      did -e new 17
    }
  }
  elseif ($did == 20) || ($did == 21) {
    did -b new 24
  }
  elseif ($did == 22) {
    did -e new 24    
  }
  elseif ($did == 24) {
    did -o new 23 1 $sfile($mircdir,Select a sound file,Select)
  }
}
dialog -l alarm {
  title "ALARM"
  size -1 -1 130 50
  option dbu
  text "", 1, 3 9 124 10, center
  text ":", 6, 77 26 5 8, center
  edit "00", 3, 65 25 12 10, limit 2
  text ":", 7, 93 26 5 8, center
  edit "00", 4, 81 25 12 10, limit 2
  edit "00", 5, 97 25 12 10, limit 2
  button "", 2, 65 36 45 12, ok
  box "ALARM", 8, 1 1 128 22
  button "Dismiss", 9, 17 31 45 12, cancel
  text "", 10, 114 26 25 8, hide
}
dialog -l new {
  title "NEW ALARM"
  size -1 -1 157 119
  option dbu
  tab "Duration", 9, 1 1 154 62
  tab "Time", 10
  edit , 1, 14 24 124 10
  edit "00", 3, 35 47 12 10, tab 9 limit 2
  text ":", 6, 47 48 5 8, tab 9 center
  edit "00", 4, 51 47 12 10, tab 9 limit 2
  text ":", 7, 63 48 5 8, tab 9 center
  edit "00", 5, 67 47 12 10, tab 9 limit 2
  text "Duration:", 11, 10 48 25 8, tab 9
  edit "", 12, 49 47 20 10, tab 10
  text "Time:", 13, 35 48 13 8, tab 10
  box "Alarm Name:", 8, 12 16 128 22
  box "Allow Snooze", 16, 88 40 50 21
  check "", 15, 92 48 10 10
  edit "0", 17, 103 48 14 10, disable
  text Max, 18, 118 49 10 8
  box "Sound", 19, 2 64 105 53
  radio "Beep", 20, 6 72 50 10
  radio "No Sound", 21, 6 82 50 10
  radio "Custom", 22, 6 92 50 10
  edit "Selece a file...", 23, 10 103 50 10, disable autohs
  button "Browse...", 24, 62 103 37 12, disable
  button "SET", 14, 114 81 37 12, tab 10
  button "SET", 2, 114 81 37 12, tab 9
}
alias -l alarm {
  tokenize 131 $1-
  var %n = 1
  while ($dialog(alarm $+ %n)) {
    inc %n
  }
  dialog -omdk alarm $+ %n alarm
  did -a alarm $+ %n 1 $$3-
  did -a alarm $+ %n 2 SNOOZE $+ $chr(40) $+ $2 $+ $chr(41)
  did -a alarm $+ %n 10 $1
  if ($2 == 0) {
    did -b alarm $+ %n 2-5
  }
  if ($1 == 0) { 
  } 
  elseif ($1 == 1) {
    beep
    .timeralrm 0 2 /beep
  }
  else {
    if ($right($1,4) = .mp3) {
      var %x = -p
    }
    elseif ($right($1,4) = .wav) {
      var %x = -w
    }
    elseif ($right($1,4) = .mid) {
      var %x = -m
    }
    splay %x $1
  }
}
alias -l aalarm {
  var %ts = $timer(0)
  while (%ts > 0) {
    if ($chr(131) isin $timer(%ts).com) {
      var %als = %als $+ %ts $+ $chr(44)
    }      
    dec %ts
  }
  var %tn = $numtok(%als,44)
  while (%tn > 0) { 
    var %tt = $gettok(%als,%tn,44)
    var %a = $deltok($timer(%tt).com,1,32)
    if ($gettok(%a,1,131) == 0) var %s = None
    elseif ($gettok(%a,1,131) == 1) var %s = Beep
    else var %s = $gettok(%a,1,131)
    if ($timer(%tt).time) var %at = @ $v1
    else var %at = in $duration($timer(%tt).secs,3)
    did -a aalarm 1 $gettok(%a,3,131)
    did -a aalarm 2 %s
    did -a aalarm 3 %at
    did -a aalarm 11 $gettok(%a,2,131)
    did -a aalarm 8 $timer(%tt)
    dec %tn
  }
}
on *:dialog:aalarm:sclick:*: {
  if ($did == 1) {
    did -c aalarm 2 $did(aalarm,1).sel
    did -c aalarm 3 $did(aalarm,1).sel
    did -c aalarm 11 $did(aalarm,1).sel
  }
  elseif ($did == 2) {
    did -c aalarm 1 $did(aalarm,2).sel
    did -c aalarm 3 $did(aalarm,2).sel
    did -c aalarm 11 $did(aalarm,2).sel
  }
  elseif ($did == 3) {
    did -c aalarm 1 $did(aalarm,3).sel
    did -c aalarm 2 $did(aalarm,3).sel
    did -c aalarm 11 $did(aalarm,3).sel
  }
  elseif ($did == 11) {
    did -c aalarm 1 $did(aalarm,11).sel
    did -c aalarm 2 $did(aalarm,11).sel
    did -c aalarm 3 $did(aalarm,11).sel
  }
  elseif ($did == 10) {
    .timer [ $+ [ $did(aalarm,8,$did(aalarm,1).sel) ] ] off
    echo 11 -e $timestamp " $+ $did(aalarm,1,$did(aalarm,1).sel) $+ " Alarm killed.
    did -r aalarm 1-3,8,11
    aalarm
  }
  elseif ($did == 9) {
    did -r aalarm 1-3,8,11
    aalarm
  }
  elseif ($did == 13) {
    dialog -mk new new
    did -c new 20 
  }
}
dialog -l aalarm {
  title "Active Alarms"
  size -1 -1 224 75
  option dbu
  list 1, 2 8 70 50, size
  list 2, 74 8 92 50, size
  list 3, 168 8 33 50, size
  text "Name", 5, 2 0 14 8
  text "Sound", 6, 74 0 24 8
  text "Snooze", 7, 198 0 18 8
  button "Kill", 10, 94 60 35 12
  button "Close", 4, 131 60 35 12, ok
  list 11, 203 8 15 50, size
  text "Time", 12, 166 0 24 8
  list 8, 16 64 15 50, hide size
  button "Refresh", 9, 57 60 35 12
  button "New", 13, 197 60 26 12
}
menu channel,status {
  Alarm
  .New Alarm:/dialog -mk new new | /did -c new 20 
  .Active Alarms:/dialog -mk aalarm aalarm | /aalarm
}

Comments

Sign in to comment.
MashhitDK   -  Mar 27, 2012

Not tested... but I like the idea... only use mIRC for bot tho.
KVirc > mIRC

 Respond  
Burrito   -  Sep 16, 2010

Nice. Havent tested but look good.

 Respond  
smilinbob   -  Sep 16, 2010

Yeah that is on my list of functions to add, as well as a monitor to see what alarms are active and how much time is left on them. Might work on that today.

 Respond  
napa182   -  Sep 16, 2010

maybe add a function to add ur own sounds or music. cuz beeps are boring ;x

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.