Guest User

Hunt Group x7000 script

a guest
Mar 10th, 2010
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. session.answer();
  2. var domain_name = session.getVariable("domain_name");
  3. var extension = '7000';
  4. var result;
  5. var timeoutpin = 7500;
  6.  
  7. var objdate = new Date();
  8. var adjusthours = 0; //Adjust Server time that is set to GMT 7 hours
  9. var adjustoperator = "-"; //+ or -
  10. if (adjustoperator == "-") {
  11. var objdate2 = new Date(objdate.getFullYear(),objdate.getMonth(),objdate.getDate(),(objdate.getHours() - adjusthours),objdate.getMinutes(),objdate.getSeconds());
  12. }
  13. if (adjustoperator == "+") {
  14. var objdate2 = new Date(objdate.getFullYear(),objdate.getMonth(),objdate.getDate(),(objdate.getHours() + adjusthours),objdate.getMinutes(),objdate.getSeconds());
  15. }
  16. var Hours = objdate2.getHours();
  17. var Mins = objdate2.getMinutes();
  18. var Seconds = objdate2.getSeconds();
  19. var Month = objdate2.getMonth() + 1;
  20. var Date = objdate2.getDate();
  21. var Year = objdate2.getYear()
  22. var Day = objdate2.getDay()+1;
  23. var exit = false;
  24.  
  25. function get_sofia_contact(extension,domain_name, profile){
  26. if (profile == "auto") {
  27. profile = "internal";
  28. session.execute("set", "sofia_contact_"+extension+"=${sofia_contact("+profile+"/"+extension+"@"+domain_name+")}");
  29. sofia_contact = session.getVariable("sofia_contact_"+extension);
  30.  
  31. if (sofia_contact == "error/user_not_registered") {
  32. profile = "external";
  33. session.execute("set", "sofia_contact_"+extension+"=${sofia_contact("+profile+"/"+extension+"@"+domain_name+")}");
  34. sofia_contact = session.getVariable("sofia_contact_"+extension);
  35. }
  36. }
  37. else {
  38. session.execute("set", "sofia_contact_"+extension+"=${sofia_contact("+profile+"/"+extension+"@"+domain_name+")}");
  39. sofia_contact = session.getVariable("sofia_contact_"+extension);
  40. }
  41. console_log( "info", "sofia_contact "+profile+": "+sofia_contact+".\n" );
  42. return sofia_contact;
  43. }
  44.  
  45.  
  46. function mycb( session, type, obj, arg ) {
  47. try {
  48. if ( type == "dtmf" ) {
  49. console_log( "info", "digit: "+obj.digit+"\n" );
  50. if ( obj.digit == "#" ) {
  51. //console_log( "info", "detected pound sign.\n" );
  52. exit = true;
  53. return( false );
  54. }
  55.  
  56. dtmf.digits += obj.digit;
  57.  
  58. if ( dtmf.digits.length >= digitmaxlength ) {
  59. exit = true;
  60. return( false );
  61. }
  62. }
  63. } catch (e) {
  64. console_log( "err", e+"\n" );
  65. }
  66. return( true );
  67. } //end function mycb
  68.  
  69.  
  70. dialed_extension = session.getVariable("dialed_extension");
  71. domain_name = session.getVariable("domain_name");
  72. domain = session.getVariable("domain");
  73. us_ring = session.getVariable("us-ring");
  74. caller_id_name = session.getVariable("caller_id_name");
  75. caller_id_number = session.getVariable("caller_id_number");
  76. effective_caller_id_name = session.getVariable("effective_caller_id_name");
  77. effective_caller_id_number = session.getVariable("effective_caller_id_number");
  78. outbound_caller_id_name = session.getVariable("outbound_caller_id_name");
  79. outbound_caller_id_number = session.getVariable("outbound_caller_id_number");
  80. session.execute("set", "ringback=${hold_music}"); //set to ringtone
  81. session.execute("set", "transfer_ringback=${hold_music}"); //set to ringtone
  82. session.execute("set", "ignore_early_media=true"); //set to music
  83. session.execute("set", "call_timeout=30");
  84. session.execute("export", "call_timeout=30");
  85. session.execute("set", "continue_on_fail=true");
  86. session.execute("set", "hangup_after_bridge=true");
  87.  
  88. //console_log( "info", "dialed extension:"+dialed_extension+".\n" );
  89. //console_log( "info", "domain: "+domain+".\n" );
  90. //console_log( "info", "us_ring: "+us_ring+".\n" );
  91. //console_log( "info", "domain: "+domain+".\n" );
  92. //console_log( "info", "domain_name: "+domain_name+".\n" );
  93.  
  94. //console_log( "info", "action call now don't wait for dtmf\n" );
  95. if ( session.ready() ) {
  96. session.answer();
  97.  
  98. sofia_contact_1000 = get_sofia_contact("1000",domain_name, "auto");
  99.  
  100. session.execute("bridge", sofia_contact_1000);
  101. session.execute("bridge", "sofia/gateway/flowroute.com/16194548924");
  102.  
  103. //timeout
  104. if (session.getVariable("originate_disposition")!="SUCCESS" && session.getVariable("originate_disposition")!="ORIGINATOR_CANCEL"){
  105. session.execute("info", "");
  106. session.execute("transfer", "*991000");
  107. }
  108.  
  109. //clear variables
  110. dialed_extension = "";
  111. new_extension = "";
  112. domain_name = "";
  113. domain = "";
  114. } //end if session.ready
RAW Paste Data