2 недели мучительного копания в доках и инете и написал скрипт! Вот он, только не вычищеный от мусора и лишних переменных. Вешается обязательно на ВХОДЯЩИЙ диал-пир.
proc init { } {
global param
set param(interruptPrompt) true
set param(abortKey) *
set param(terminationKey) #
global i
set i 0
global dest
set dest 7520
}
proc act_Setup { } {
global dest
puts "\nproc init_perCallvars"
global ani
global dnis
global i
set i 0
set ani ""
set dnis ""
set dest 7520
set ani [infotag get leg_ani]
puts "\nANI $ani"
set dnis [infotag get leg_dnis]
puts "\nDNIS $dnis"
set out [infotag get leg_outgoing]
puts "\nOUT $out"
set in [infotag get leg_incoming]
puts "\nIN $in"
set nam [infotag get leg_display_info]
puts "\nNAME $nam"
puts "\nDEST $dest"
# set callInfo(newguid) true
# set callInfo(mode) "rotary"
# set callInfo(usrDstAddr) “7520”
# set callInfo(usrSrcAddr) $ani
# set callInfo(displayInfo) $nam
#
set callInfo(alertTime) 20
# set callInfo(destinationNum) "7520"
# set callInfo(originationNum) $ani
# set new_gtd [object create gtd gtd_setup_ind IAM]
leg setupack leg_incoming
leg proceeding leg_incoming
leg connect leg_incoming
fsm setstate PLACECALL
call_Place
return
}
proc call_Place {} {
global dest
leg setup $dest callInfo leg_outgoing
fsm setstate PAUSE
}
proc call_SendPause { } {
global dnis
global dest
puts "\nSTATUS IS - [infotag get evt_status]\n"
set status [infotag get evt_status]
set out [infotag get leg_outgoing]
puts "\nOUTpause $out"
if {$status == "ls_000"} {
puts "\nCALL ACTIVE\n"
puts "\nDEST IS - $dnis\n"
media play leg_outgoing %s2000
puts "\nPAUSE PLAYED\n"
} else {
if {$status == "ls_007" && $dest == "7520"} {
puts "\nCALL RESTART\n"
puts "\nDEST IS - 7521\n"
set dest 7521
fsm setstate PLACECALL
call_Place
return
}
puts "\nCALL FAILED\n"
call close
}
}
proc call_SendDigit { } {
global i
global dnis
global digit
set out [infotag get leg_outgoing]
puts "\nOUTdigit $out"
if {$i < [string length $dnis]} {
set digit [string index $dnis $i]
leg senddigit leg_outgoing $digit -t 200
media play leg_outgoing %s400
incr i
}
if {$i == [string length $dnis]} {
puts "\nDTMF COMPLETE\n"
fsm setstate CALLACTIVE
}
}
proc call_Activ {} {
connection create leg_incoming leg_outgoing
set out [infotag get leg_outgoing]
puts "\nOUTconnect $out"
}
proc call_Cleanup { } {
call close
}
init
#----------------------------------
# State Machine
#----------------------------------
set FSM(any_state,ev_disconnected) "call_Cleanup,same_state"
set FSM(CALL_INIT,ev_handoff) "act_Setup,PLACECALL"
set FSM(CALL_INIT,ev_setup_indication) "act_Setup,PLACECALL"
set FSM(PLACECALL,ev_any_event) "call_Place,PAUSE"
set FSM(PAUSE,ev_setup_done) "call_SendPause,PAUSESENT"
set FSM(PAUSESENT,ev_media_done) "call_SendDigit,same_state"
set FSM(CALLACTIVE,ev_disconnected) "call_Cleanup,CALLDISCONNECTED"
set FSM(CALLACTIVE,ev_media_done) "call_Activ,same_state"
set FSM(CALLDISCONNECTED,ev_disconnected) "call_Cleanup,same_state"
set FSM(CALLDISCONNECTED,ev_disconnect_done) "call_Cleanup,same_state"
fsm define FSM CALL_INIT