; record.conf:
; An interactive application to record soundfiles used within
; the system.  Not in great shape right now.

; Once here, main menu is:
;   1: Record a phrase
;   2: Listen to a phrase
;   3: Listen to all phrase names
;
;   1: Record a phrase
;      Prompt user to enter phrase number
;      Message: wait for beep, then press # when finished
;      Wait for phrase number to be entered
;      Record phrase file until # is pressed
;      Wait, then play back phrase
;      Return to main record menu
;
;   2: Listen to a phrase
;      Prompt user to enter phrase number
;      Wait for phrase number to be entered
;      Play phrase file
;      Return to main record menu
;
;   3: Play all phrase names
;
; ----------------------------------------------
; ---- Files used internally by record.conf ----
; ----------------------------------------------
; user_sounds/record/main_menu
;   "1 to record a phrase, 2 to listen to a phrase, 3 to hear all phrase names"
; user_sounds/record/enter_phrase_number
;   "enter the phrase number now"
; user_sounds/record/record_instructions
;   "Wait for the beep, then press # when finished"
;
; ALSO: the "-name" version of all phrases managed by record.conf
;
; --------------------------------------------------
; ---- Phrases and files managed by record.conf ----
; --------------------------------------------------
; Phrase# | File                         | Description
; 1       | main-external_greeting       | main greeting (external calls)
; 2       | main-internal_greeting       | main greeting (internal calls)
; 3       | calling_card_greeting        | calling card greeting
; 71      | janet-dnd                    | Janet DND message
; 81      | daniel-dnd                   | Daniel DND message
;
; Phrase# plus * records the '-name' version

; ############################################################################
; Record phrases macros
; ############################################################################
;
[macro-record-record_phrase]
;   ${ARG1} - Phrase file
exten = s,1,Wait(1)
exten = s,2,GotoIf($["${ARG1:0:1}" = "*"]?3:4)
exten = s,3,Goto(s-is_name,1)
exten = s,4,Goto(s-not_name,1)

; If the phrase number starts with '*', this is the phrase name
exten = s-is_name,1,Goto(s-all,1)

; If the phrase number doesn't start with '*', this is the phrase
exten = s-not_name,1,Playback(user_sounds/${ARG1}-name)
exten = s-not_name,2,Goto(s-all,1)

exten = s-all,1,Playback(user_sounds/record/record_instructions)
exten = s-all,2,Wait(2) ; give yourself 2 secs to take a breath and wait for beep
exten = s-all,3,Record(user_sounds/${ARG1}:ulaw)
exten = s-all,4,Wait(2)
exten = s-all,5,Playback(beep)
exten = s-all,6,Playback(user_sounds/${ARG1})
exten = s-all,7,Playback(beep)
exten = s-all,8,Goto(app-record-main,s,1)

[macro-record-play_phrase]
;   ${ARG1} - Phrase file
exten = s,1,Wait(1)
exten = s,2,Playback(user_sounds/${ARG1})
exten = s,3,Goto(app-record-main,s,1)

[macro-record-play_phrase_name]
;   ${ARG1} - Phrase file
exten = s,1,Playback(user_sounds/${ARG1})

; ############################################################################
; Record phrases app
; ############################################################################

[app-record-main]
;   1: Record a phrase
;   2: Listen to a phrase
;   3: Listen to all phrase names
include = app-record-exceptions
exten = s,1,Answer ; Answer the line
exten = s,2,BackGround(user_sounds/record/main_menu)
exten = 1,1,Goto(app-record-record_phrase,s,1)
exten = 2,1,Goto(app-record-play_phrase,s,1)
exten = 3,1,Goto(app-record-name_phrases,s,1)

[app-record-record_phrase]
include = app-record-exceptions
exten = s,1,Wait(1)
exten = s,2,Background(user_sounds/record/enter_phrase_number)

exten = 1,1,Macro(record-record_phrase,main-external_greeting)
exten = *1,1,Macro(record-record_phrase,main-external_greeting-name)
exten = 2,1,Macro(record-record_phrase,main-internal_greeting)
exten = *2,1,Macro(record-record_phrase,main-internal_greeting-name)
exten = 3,1,Macro(record-record_phrase,calling_card_greeting)
exten = *3,1,Macro(record-record_phrase,calling_card_greeting-name)
exten = 71,1,Macro(record-record_phrase,77-dnd)
exten = *71,1,Macro(record-record_phrase,77-dnd-name)
exten = 81,1,Macro(record-record_phrase,78-dnd)
exten = *81,1,Macro(record-record_phrase,78-dnd-name)

[app-record-play_phrase]
include = app-record-exceptions
exten = s,1,Wait(1)
exten = s,2,Background(user_sounds/record/enter_phrase_number)

exten = 1,1,Macro(record-play_phrase,main-external_greeting)
exten = *1,1,Macro(record-play_phrase,main-external_greeting-name)
exten = 2,1,Macro(record-play_phrase,main-internal_greeting)
exten = *2,1,Macro(record-play_phrase,main-internal_greeting-name)
exten = 3,1,Macro(record-play_phrase,calling_card_greeting)
exten = *3,1,Macro(record-play_phrase,calling_card_greeting-name)
exten = 71,1,Macro(record-play_phrase,77-dnd)
exten = *71,1,Macro(record-play_phrase,77-dnd-name)
exten = 81,1,Macro(record-play_phrase,78-dnd)
exten = *81,1,Macro(record-play_phrase,78-dnd-name)

[app-record-name_phrases]
include = app-record-exceptions
exten = s,1,Wait(1)
exten = s,2,Macro(record-play_phrase_name,main-external_greeting-name)
exten = s,3,Macro(record-play_phrase_name,main-internal_greeting-name)
exten = s,4,Macro(record-play_phrase_name,calling_card_greeting-name)
exten = s,5,Macro(record-play_phrase_name,77-dnd-name)
exten = s,6,Macro(record-play_phrase_name,78-dnd-name)
exten = s,7,Goto(app-record-main,s,1)

[app-record-exceptions]
exten = t,1,Hangup

; Anything unknown goes to main menu
exten = i,1,playback(vm-extension)
exten = i,2,sayalpha(${INVALID_EXTEN})
exten = i,3,playback(invalid)
exten = i,4,Goto(app-record-main,s,1)

