fork download
  1.  
  2. #-------------------------------------------------------------------
  3. # Application Teleperformance-ani_v3.tcl
  4. #-------------------------------------------------------------------
  5. #
  6. # Copyright (c) 1998, 1999, 2000 by Cisco Systems, Inc.
  7. # All rights reserved.
  8. #-------------------------------------------------------------------
  9. #
  10. # This tcl script replaces the SESSION application for a POTS call
  11. # leg. If the CLID matches one of the particular patterns, it's
  12. # translation into a new CLID is done. In some cases, presentation
  13. # restriction is forced. Otherwise CLID gets the default value.
  14. #
  15. # If DID is configured, just place the call to the DNIS. Otherwise,
  16. # output dial-tone and collect digits from the caller against the
  17. # dial-plan. Then place the call. If successful, connect it up,
  18. # otherwise the caller should hear a busy or congested signal.
  19.  
  20. proc act_Setup { } {
  21. global clid
  22. global dest
  23. global beep
  24. global clid_new
  25.  
  26. set beep 0
  27.  
  28. if { [infotag get leg_isdid] } {
  29. set dest [infotag get leg_dnis]
  30. set clid [infotag get leg_ani]
  31.  
  32. leg proceeding leg_incoming
  33.  
  34. set clid_len [string length $clid]
  35. set clid5 [string range $clid 0 4]
  36. set clid7 [string range $clid 0 6]
  37. set clid8 [string range $clid 0 7]
  38. set clid9 [string range $clid 0 8]
  39. set clid6a [string range $clid 5 5]
  40. set clid7a [string range $clid 6 6]
  41. set clid8a [string range $clid 7 7]
  42. set clid9a [string range $clid 8 8]
  43. set clid10a [string range $clid 9 9]
  44. set clid_rst [string range $clid 2 $clid_len]
  45.  
  46.  
  47. # Geo A-numbers 211*
  48. if { ($clid7 == "2117606") ||
  49. ($clid9 == "211300095") ||
  50. ($clid9 == "211300166") ||
  51. ($clid8 == "21118807" && $clid9a >= "5" && $clid9a <= "9") ||
  52. ($clid8 == "21118839" && $clid9a >= "0" && $clid9a <= "2") ||
  53. ($clid8 == "21188010" && $clid9a >= "0" && $clid9a <= "4") ||
  54. ($clid8 == "21118106" && $clid9a >= "0" && $clid9a <= "4") ||
  55. ($clid8 == "21118708" && $clid9a >= "0" && $clid9a <= "4") } {
  56.  
  57.  
  58. set callInfo(originationNum) $clid
  59. set callInfo(originationNumPI) presentation_allowed
  60. set callInfo(originationNumSI) network_provided
  61.  
  62. # Geo A-numbers 210*
  63. } elseif { ($clid7 == "2109490" && $clid8a >= "5" && $clid8a <= "9") ||
  64. ($clid7 == "2109468") ||
  65. ($clid7 == "2109468") } {
  66.  
  67. set callInfo(originationNum) $clid
  68. set callInfo(originationNumPI) presentation_allowed
  69. set callInfo(originationNumSI) network_provided
  70.  
  71.  
  72. # Cellphone A-numbers
  73. } elseif { ($clid7 == "6944489") ||
  74. ($clid7 == "6933790") ||
  75. ($clid7 == "6944483" && $clid8a == "0") ||
  76. ($clid7 == "6944483" && $clid8a >= "6" $clid8a <= "9") ||
  77. ($clid7 == "6944482" && $clid8a >= "0" $clid8a <= "1") ||
  78. ($clid7 == "6944482" && $clid8a >= "3" $clid8a <= "5") } {
  79.  
  80.  
  81. set callInfo(originationNum) $clid
  82. set callInfo(originationNumPI) presentation_allowed
  83. set callInfo(originationNumSI) network_provided
  84.  
  85.  
  86. # Fallback to KEFALIKO
  87.  
  88. } else {
  89.  
  90. set dest_new 2109468000
  91. set callInfo(originationNum) $dest_new
  92. set callInfo(originationNumPI) presentation_allowed
  93. set callInfo(originationNumSI) network_provided
  94.  
  95. }
  96.  
  97. leg setup $dest callInfo leg_incoming
  98. fsm setstate PLACECALL
  99. } else {
  100. leg setupack leg_incoming
  101. playtone leg_incoming tn_dial
  102.  
  103. set param(dialPlan) true
  104. leg collectdigits leg_incoming param
  105. }
  106.  
  107.  
  108. }
  109.  
  110. proc act_GotDest { } {
  111. global dest
  112.  
  113. set status [infotag get evt_status]
  114.  
  115. if { $status == "cd_004" } {
  116. set dest [infotag get evt_dcdigits]
  117. leg proceeding leg_incoming
  118. leg setup $dest callInfo leg_incoming
  119.  
  120. } else {
  121. puts "\nCall [infotag get con_all] got event $status collecting destination"
  122. # use invalid-number cause code
  123. leg disconnect leg_incoming -c28
  124. call close
  125. }
  126. }
  127.  
  128.  
  129. proc act_CallSetupDone { } {
  130. global beep
  131.  
  132. set status [infotag get evt_status]
  133.  
  134. if { $status == "ls_000"} {
  135.  
  136. set creditTimeLeft [infotag get leg_settlement_time leg_all]
  137.  
  138. if { ($creditTimeLeft == "unlimited") ||
  139. ($creditTimeLeft == "uninitialized") } {
  140. puts "\n Unlimited Time"
  141. } else {
  142. # start the timer for ...
  143. if { $creditTimeLeft < 10 } {
  144. set beep 1
  145. set delay $creditTimeLeft
  146. } else {
  147. set delay [expr $creditTimeLeft - 10]
  148. }
  149. timer start leg_timer $delay leg_incoming
  150. }
  151. } else {
  152. puts "Call [infotag get con_all] got event $status collecting destination"
  153. call close
  154. }
  155. }
  156.  
  157. proc act_Timer { } {
  158. global beep
  159. global incoming
  160. global outgoing
  161.  
  162. set incoming [infotag get leg_incoming]
  163. set outgoing [infotag get leg_outgoing]
  164.  
  165. if { $beep == 0 } {
  166. #insert a beep ...to the caller
  167. connection destroy con_all
  168. set beep 1
  169. } else {
  170. connection destroy con_all
  171. fsm setstate LASTWARN
  172. }
  173. }
  174.  
  175. proc act_LastWarn { } {
  176. media play leg_incoming flash:out_of_time.au
  177. }
  178.  
  179. proc act_Destroy { } {
  180. media play leg_incoming flash:beep.au
  181. }
  182.  
  183. proc act_Beeped { } {
  184. global incoming
  185. global outgoing
  186.  
  187. connection create $incoming $outgoing
  188. }
  189.  
  190. proc act_ConnectedAgain { } {
  191. timer start leg_timer 10 leg_incoming
  192. }
  193.  
  194. proc act_Ignore { } {
  195. # Dummy
  196. puts "Event Capture"
  197. }
  198.  
  199. proc act_Cleanup { } {
  200. call close
  201. }
  202.  
  203.  
  204. #------------------
  205. # State Machine
  206. #----------------------------------
  207. set fsm(any_state,ev_disconnected) "act_Cleanup same_state"
  208.  
  209. set fsm(CALL_INIT,ev_setup_indication) "act_Setup GETDEST"
  210.  
  211. set fsm(GETDEST,ev_collectdigits_done) "act_GotDest PLACECALL"
  212.  
  213. set fsm(PLACECALL,ev_setup_done) "act_CallSetupDone CALLACTIVE"
  214.  
  215.  
  216. set fsm(CALLACTIVE,ev_leg_timer) "act_Timer INSERTBEEP"
  217. set fsm(INSERTBEEP,ev_destroy_done) "act_Destroy same_state"
  218. set fsm(INSERTBEEP,ev_media_done) "act_Beeped same_state"
  219. set fsm(INSERTBEEP,ev_create_done) "act_ConnectedAgain CALLACTIVE"
  220.  
  221. set fsm(LASTWARN,ev_destroy_done) "act_LastWarn CALLDISCONNECT"
  222.  
  223. set fsm(CALLACTIVE,ev_disconnected) "act_Cleanup CALLDISCONNECT"
  224. set fsm(CALLDISCONNECT,ev_disconnected) "act_Cleanup same_state"
  225. set fsm(CALLDISCONNECT,ev_media_done) "act_Cleanup same_state"
  226. set fsm(CALLDISCONNECT,ev_disconnect_done) "act_Cleanup same_state"
  227. set fsm(CALLDISCONNECT,ev_leg_timer) "act_Cleanup same_state"
  228.  
  229.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty