; AUSZUG AUS
; extensions.conf
[wake_up]
exten => wake_up,1,Goto(wake_up,wake_up,2) ;Verschiedene Schreibweisen auswerten
exten => Wake_Up,1,Goto(wake_up,wake_up,2)
exten => Wake_up,1,Goto(wake_up,wake_up,2)
exten => 70,1,Goto(wake_up,wake_up,2)
exten => wake_up,2,GotoIf($[ ${LEN($CALLERID(name))} < 2 ]?3:5) ;Wenn CallerID-Name nicht vorhanden oder zu kurz
exten => wake_up,3,Set(ToDial=${CALLERIDNUMBER}) ;Nummer zum wählen verwenden
exten => wake_up,4,Goto(wake_up,6)
exten => wake_up,5,Set(ToDial=${CALLERIDNAME}) ;Name verwenden
exten => wake_up,6,Answer
exten => wake_up,7,Wait(1)
exten => wake_up,8,Read(EnteredDate,censec_wakeup-enterdate,8) ;8stellige Zahl als Datum einlesen
exten => wake_up,9,SetVar(edYear=${EnteredDate:-8:4}) ;Datum in Bestandteile aufgliedern, Jahr
exten => wake_up,10,SetVar(edMonth=${EnteredDate:-4:2}) ;Monat
exten => wake_up,11,SetVar(edDay=${EnteredDate:-2}) ;Tag
exten => wake_up,12,GotoIf($[${edYear} = 0000]?s-deletewakeup|1) ;Wenn Jahr = 0000, dann
exten => s-deletewakeup,1,TrySystem(rm /var/spool/asterisk/outgoing/WakeUp_${ToDial}.call) ;Wakeup-call löschen
exten => s-deletewakeup,n,Wait(1)
exten => s-deletewakeup,n,Playback(censec_wakeup-deleted)
exten => s-deletewakeup,n,Hangup()
exten => wake_up,13,GotoIf($[${edMonth} > 12 | ${edDay} > 31]?s-datesyntax|1) ;Datum prüfen
exten => s-datesyntax,1,Playback(censec_dateincorrect) ;Über falsche Datumseingabe beschweren
exten => s-datesyntax,2,Goto(wake_up,8) ;Datum nochmal eingeben lassen
exten => wake_up,14,Read(EnteredTime,censec_wakeup-entertime,4) ;4stellige Zahl als Uhrzeit einlesen
exten => wake_up,15,SetVar(etHours=${EnteredTime:-4:2}) ;Uhrzeit in Bestandteile aufgliedern, Stunden
exten => wake_up,16,SetVar(etMinutes=${EnteredTime:-2}) ;Minuten
exten => wake_up,17,GotoIf($[${etHours} > 23 | ${etMinutes} > 59]?s-timesyntax|1) ;Uhrzeit prüfen
exten => s-timesyntax,1,Playback(censec_timeincorrect) ;Über falsche Uhrzeiteingabe beschweren
exten => s-timesyntax,2,Goto(wake_up,14) ;Uhrzeit nochmal eingeben lassen
exten => wake_up,18,Wait(1)
exten => wake_up,19,TrySystem(echo "" > /tmp/WakeUp_${ToDial}.call) ;Callfile erstellen in temp-Verzeichnis
exten => wake_up,20,TrySystem(echo "Channel: Local/auto_${ToDial}@in_sip_censec" >> /tmp/WakeUp_${ToDial}.call)
exten => wake_up,21,TrySystem(echo "CallerID: wake_up <70>" >> /tmp/WakeUp_${ToDial}.call)
exten => wake_up,22,TrySystem(echo "MaxRetries: 2" >> /tmp/WakeUp_${ToDial}.call)
exten => wake_up,23,TrySystem(echo "RetryTime: 60" >> /tmp/WakeUp_${ToDial}.call)
exten => wake_up,24,TrySystem(echo "WaitTime: 30" >> /tmp/WakeUp_${ToDial}.call)
exten => wake_up,25,TrySystem(echo "Context: wake_up" >> /tmp/WakeUp_${ToDial}.call)
exten => wake_up,26,TrySystem(echo "Extension: wake_up_autocall" >> /tmp/WakeUp_${ToDial}.call)
exten => wake_up,27,TrySystem(echo "Priority: 1" >> /tmp/WakeUp_${ToDial}.call)
exten => wake_up,28,TrySystem(touch -t ${edYear}${edMonth}${edDay}${etHours}${etMinutes} /tmp/WakeUp_${ToDial}.call) ;Änderungszeit des Callfiles anpassen
exten => wake_up,29,TrySystem(mv /tmp/WakeUp_${ToDial}.call /var/spool/asterisk/outgoing/WakeUp_${ToDial}.call) ;Callfile ins Asterisk-Verzeichnis verschieben
exten => wake_up,30,Wait(1) ;Warten, da sonst manchmal Teile der Ansagen verschluckt werden
exten => wake_up,31,Background(censec_wakeup-callsaved) ;Benutzer über erfolgreiche Speicherung informieren
exten => wake_up,31,Hangup
exten => wake_up_autocall,1,Answer
exten => wake_up_autocall,n,Wait(1)
exten => wake_up_autocall,n,Set(LANGUAGE()=de) ;Ohne diesen Befehl wird die englische Ansage abgespielt (???)
exten => wake_up_autocall,n,Playback(censec_wakeup-yourwakeupcall)
;exten => wake_up_autocall,n,MP3Player(/var/lib/asterisk/mohmp3/fpm-world-mix.mp3)
exten => wake_up_autocall,n,Wait(2)
exten => wake_up_autocall,n,Hangup
exten => wake_up_delete,1,Goto(wake_up,wake_up_delete,2) ;Verschiedene Schreibweisen auswerten
exten => Wake_up_delete,1,Goto(wake_up,wake_up_delete,2)
exten => Wake_Up_Delete,1,Goto(wake_up,wake_up_delete,2)
exten => 71,1,Goto(wake_up,wake_up_delete,2)
exten => wake_up_delete,2,GotoIf($[ ${LEN($CALLERID(name))} < 2 ]?3:5) ;Wenn CallerID-Name nicht vorhanden oder zu kurz
exten => wake_up_delete,3,Set(ToDial=${CALLERIDNUMBER}) ;Nummer zum wählen verwenden
exten => wake_up_delete,4,Goto(wake_up,6)
exten => wake_up_delete,5,Set(ToDial=${CALLERIDNAME}) ;Name verwenden
exten => wake_up_delete,6,TrySystem(rm /var/spool/asterisk/outgoing/WakeUp_${ToDial}.call) ;Wakeup-call löschen
exten => wake_up_delete,7,Wait(1)
exten => wake_up_delete,8,Playback(censec_wakeup-deleted)
exten => wake_up_delete,9,Hangup()