maybe some one can help me

Catalog of dial plans
Post Reply
winter
Posts: 2
Joined: Fri Oct 07, 2011 9:19 pm

maybe some one can help me

Post by winter » Fri Oct 07, 2011 9:25 pm

Hello all :) Im kind of new to the sipsorcery stuff but not from pap2 and sip it self
I been looking at my dialing plan and everything works great i can IN & OUT call with out a problem but there is one thing i would love to be able to do.
i want to be able to call this for ex : '742' => '6506441934@podlinez.net', # Prairie Home Companion's
but for some reason any time i dial SPEEDDIAL 742 all i get is fast busy seems like it never dials out
I copied my dial plan i have been using for a bit now but maybe some one here knows the reason why i can not call that or any podlinez

I'm using GOOGLE VOICE + IPKALL + SIPSORCERY + PAP2 everything works but the dialing of PODLINEZ
ANYONE WANNA HELP

Code: Select all


class Hash; alias :+ :merge; end; Home,Mobile,Work,Gizmo = 1,2,3,7

# --------BEGIN MANDATORY ENTRIES SECTION-----------------------------#                     
  
Area = '646'          # my area code, this will be added to 7-digit dialouts
Tz   = -5             # my time zone (GMT format, e.g. Eastern = -5, Central = -6)
  
# *************** Google Voice Configuration Section *********************

Credentials = { :usr => 'xxxxxxxxxx@gmail.com', :pwd => 'xxxxxxx' } # Your GV login and password

# Your account description is next. It should contain at least one callback
# number.

GVaccount = [
  Credentials + { :cb => '(360) xxx-xxxx' }, # IPKall callback number
]

# *************** SIP Provider Configuration Section *********************
 
VSPtab = {
  '0' => '00 @ F9',                # Future-nine default route
  '2' => '02 @ F9',                # Future-nine grey route
  '3' => '03 @ F9',                # Future-nine white route
  '4' => '04 @ F9',                # Future-nine premium route
  '5' => '@ Sipgate',              # sipgate
  '7' => '@ Gizmo',                # gizmo 
}
 
# ------ END MANDATORY ENTRIES SECTION-----------------------------#                     
  
  
# ------ BEGIN OPTIONAL PARAMETERS SECTION ------------------------#                     

# Speed dial entries. Format: "short code" => "destination (POTS or SIP)"
  
Speeddial = {
  '303' => '303@sip.blueface.ie',      # Blueface speaking clock (Ireland time)
  '266' => '4153767253@podlinez.net',  # CNN Headlines (266 = "CNN")
  '677' => '8186882773@podlinez.net',  # NPR's most e-mailed stories (677 ="NPR")                     
  '742' => '6506441934@podlinez.net',  # Prairie Home Companion's, or PHC's
                                       # News from Lake Wobegon (742 = "PHC")
  '932' => '7755333366',               # Columbus OH-based national weather (932 = "WEA[ther]")                    
}

# CNAM table: number in ENUM format => caller's name

CNAM = {

}
# Uncomment next line and insert your White Pages API key, if you have it
WP_key = 'XXXXXXXXX'      # White Pages API key

# ------ END OPTIONAL PARAMETERS SECTION ==------------------------#                     
   
# Serviced domains, must be in lowercase!

Domains  = ['sipsorcery.com','sip.sipsorcery.com','sip1.sipsorcery.com','sip2.sipsorcery.com','69.59.142.213']
Host     =  'sipsorcery.com' # incoming calls will come with this host

# Enum list from sipbroker

EnumDB = [
 'e164.org',
 'e164.info',
 'e164.arpa',
 'e164.televolution.net',
 'enum.org',
]

# Uncomment line below to enable misdialing safeguards
EnableSafeguards = 1

Allowed_Country = %w{  
1 33 36 39 41 420 44 49 7 86 883 886 90 972
}
  
# Excluded Prefixes. Provides a safeguard against accidentally calling premium
# numbers. Accepts both strings and patterns, spaces ignored
  
ExcludedPrefixes = [
   ' 1 (900 | 809)',               # USA Premium
   ' 1 \d\d\d 555 1212',           # USA Directory assistance
   '44 (9 | 55 | 70 | 84 | 87)',   # UK Premium
   '49 (1 [^567] | 900)',          # Germany Premium
   '39 (1 | 84 | 89)',             # Italy Premium 
   '420 90',                       # Czech Premium 
]
  
# ********************  s e l e c t   V S P  ***************
 
def selectVSP    # VoIP provider selection
  
  case @num
    when /^1([2-9]\d\d)/                 # North America
      case $1                            # check area code
         when "777"                   
           route(6,"Gizmo5 to Gizmo5 call")
         else
           gvcall GVaccount
           sys.Log("GoogleVoiceCall failed, routing thru Future-Nine")
           route(4,"Destination - North America non-GV")
      end
 
    when /^972(5|6)/                    # Israel mobile
       route(3,"Destination - Israel mobile")

    else
      rejectCall(603,"Number's too short, check & dial again") if @num.length < 9
      route(0,"Default route applied")
  end
end

# ****************************  C H E C K   N U M **************************

def checkNum
  @num.match(/^\D/) && return  # skip if number doesn't begin with a digit

  # Reject calls to not blessed countries and premium numbers 
  # (unless VSP was forced using #n dial prefix)
  
  rejectCall(503,"Calls to this country not allowed") unless @num.match "^(#{Allowed_Country.join('|')})"
  rejectCall(503,"Calls to #$&* not allowed") if @num.match '^(' + ExcludedPrefixes.map { |x| "(:?#{x.gsub(/\s*/,'')})" }.join('|') + ')'
end  

# **************************  C A L L    S W I T C H  **********************
  
def callswitch(num,*args)
  route                 # Initialize vars
  
  num.gsub!(/%(..)/) {$1.to_i(16).chr} # Convert %hh into ASCII
  @num = num unless @num = Speeddial[num]     # If there is speed dial entry for it...
  
  @l = "URI dialing: #{@num}" # Assume URI dialing
  unless @num =~ /@/          # If we already have URI, skip all number processing

    if @num =~ /^#(.)(.*)/    # If number starts with '#'
      @p = $1; @num = $2      # next char is VSP code
    end
 
    @num.gsub!(/[^0-9*+]/,'') # Delete all fancy chars (only digits, '+' and '*' allowed)
  
    # sub! below removes prefixes:
    #  '+' - international format
    #   00 - European style international prefix (00)
    #  011 - US style international prefix (011)
  
    unless @num.sub!(/^(\+|00|011)/,'')  # If no international prefix, process special cases below
      case @num
        when /^[2-9]\d{6,6}$/       # Local call, 7-digit number
          @num = '1' + Area + @num  # prefix it with country and area code
        when /^[01]?([2-9]\d{9,9})/ # US number with or without "1" country code
          @num = '1' + $1           # add country code and truncate number to 10-digit
        when /^\*/                  # Voxalot voicemail, echotest & other special numbers
          else
            rejectCall(603,'Wrong number, check & dial again')
      end
    end
  
    sys.Log("Number in ENUM format: #{@num}")
  
    @l = "Forced routing to provider #{@p}, template '#{VSPtab[@p]}'" # Assume user explicitly selected VSP
  
    if @p.empty?        # Automatic VSP selection?
      checkNum if defined? EnableSafeguards
      
      route                 # re-initialize variables
      selectVSP             # Pick appropriate provider for the call

      EnumDB.each do |db|   # Look in all enum databases
        if enumuri = sys.ENUMLookup("#{@num}.#{db}")
          sys.Log("ENUM entry found: '#{enumuri}' in #{db} database")
          sys.Dial(enumuri) # If yes, call that URI
          status()
          sys.Log("Call to #{enumuri} failed (#{@reason})")
        end
      end                   # ENUM not found or failed, call via regular VSP
    end # @p.empty
  end   # URI
  
  dial(*args)   # dial selected number or URI
end
  
# *******************************  D I A L  ********************************
  
def dial(*args)
  sys.Log(@l) unless @l.empty?               # for the record :)
  if tpl=VSPtab[@p.to_s]                     # if provider is in our table
    tpl.gsub!(/\s*/,'')                      # Remove spaces
    @num = tpl.gsub(/@/,@num+'@')            # Insert number before '@'
  end
  sys.Dial(@num,*args) # Dial
  status()             # We shouldn't be here! Get error code...
  sys.Log("Call failed: code #{@code}, #{@reason}")
end
  
# ****************************  G V   C A L L  *****************************

def gvcall accounts, n = [2,accounts.length].min, r = 0
  n.times do |acnt|
    a = {:num => @num, :tmo => 15, :match => '.*'}   # init with num & default values
    a.update(accounts[(acnt+r) % accounts.length])   # add other params
    a[:cb].gsub!(/\D/,'')                            # Delete all but digits
    a[:type] ||= (a[:cb] =~ /^1?777/) ? Gizmo : Home # if no type, define it depending on area code
    sys.GoogleVoiceCall *a.values_at(:usr, :pwd, :cb, :num, :match, :type, :tmo)
  end
end

# ******************************  R O U T E  *******************************
  
def route(p='', l='')
  @p = p; @l = l
end
  
# *****************************  S T A T U S  ******************************
  
def status
  begin
    @code, @reason = 487, 'Cancelled by Sipsorcery' unless @code
    sys.LastDialled.each do |ptr|
      if ptr
        ptr = ptr.TransactionFinalResponse
        @code = ptr.StatusCode; @reason = ptr.ReasonPhrase; break if @code == 200
      end
    end
  rescue
  end
end

# ************************  r e j e c t C a l l  ***************************

def rejectCall code, reason
  @code = code; @reason = reason
  sys.Respond code, reason
end 

# *************************  f o r m a t N u m  ****************************

def formatNum(num)
  case num
    when /^([17])(\d{3})(\d{3})(\d{4})$/,       # USA, Russia
         /^(380|375)(\d{2})(\d{3})(\d{4})$/,    # Ukraine, Belarus
         /^(41)(\d{2})(\d{3})(\d{4})$/,         # Swiss
         /^(972|998)(\d{2})(\d{3})(\d{4})$/,    # Israel, Uzbekistan
         /^(36)(\d)(\d{3})(\d{4})$/             # Hungary

      "+#$1 (#$2) #$3-#$4"

    when /^(33|44)(\d)(\d{2})(\d{2})(\d{2})(\d{2})$/ # France, UK

      "+#$1 (#$2) #$3 #$4 #$5 #$6"

    when /^(39|34|49)(\d+)$/                    # Italy, Spain, Germany

      "+#$1 #$2"

    when /^(420)(\d{3})(\d{3})(\d{3})$/         # Czech Republic

      "+#$1 #$2 #$3 #$4"

    else num    # No match - skip formatting
  end
end

# *******************************  M A I N  *****************************
begin
  sys.Log("** Call from #{req.Header.From} to #{req.URI.User} **") 
  sys.ExtendScriptTimeout(15)    # preventing long running dialscript time-out
  @t = Time.now + ((Tz+8)*60*60) # Get current time and adjust to local (GMT+3). SS Server is in GMT-8
  sys.Log(@t.strftime('Local time: %c'))

  if sys.In               # If incoming call...
    name = req.Header.from.FromURI.User.to_s    # Get caller ID

    # Prepend 10-digit numbers with "1" (US country code) and remove int'l prefix (if present)

    name = ('1' + name) if name =~ /^[2-9]\d\d[2-9]\d{6}$/
    name.sub!(/^(\+|00|011)/,'')   # Remove international prefixes, if any

    prs = req.URI.User.split('.')  # parse User into chunks
    trunk = prs[-2]                # get trunk name
    user  = prs[-1]                # called user name

    # Check CNAM first. If not found and US number, try to lookup caller's name in Whitepages

    if !(cname = CNAM[name]) && name =~ /^1([2-9]\d\d[2-9]\d{6})$/ && defined?(WP_key)
      url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D'http%3A%2F%2Fapi.whitepages.com%2Freverse_phone%2F1.0%2F%3Fphone%3D#{$1}%3Bapi_key%3D#{WP_key}'%20and%20itemPath%3D'wp.listings.listing'&format=json"
      if js = sys.WebGet(url,4).to_s
        cname, dname, city, state = %w(businessname displayname city state).map {|x| js =~ /"#{x}":"([^"]+)"/; $1}
        cname ||= dname; cname ||= "#{city}, #{state}" if city && state
      end
    end

    sys.Log("Caller's number: '#{name}'"); sys.Log("Caller's name:   '#{cname}'") if cname

    sys.SetFromHeader(formatNum(cname || name), nil, Host)  # Set FromName & FromHost for sys.Dial

    # Forward call to bindings
    # Change FromURI when forwarding to @local, or else Bria won't
    # find contact in its phonebook!

    callswitch("#{user}@local[fu=#{name}]",45) unless (30..745) === @t.hour*100 + @t.min # forward straight to VM from 0:30a to 7:45a

    @code, @reason = 480, "#{user} is asleep" unless @code # if nothing else, must be night hour
    @code = 486 if trunk =~ /IPCOMM/i ## *** temporary fix for IPCOMMS ***

  else                    # Outbound call ...

    # check if it's URI or phone number.
    # If destination's host is in our domain, it's a phone call
  
    num = req.URI.User.to_s; reqHost = req.URI.Host.to_s  # Get User and Host
    host = reqHost.downcase.slice(/[^:]+/)                # Convert to lowercase and delete optional ":port"
    num << '@' << reqHost unless Domains.include?(host)   # URI dialing unless host is in our domain list
  
    callswitch(num)
  
  end
  sys.Respond(@code,@reason) # Forward error code to ATA
rescue
   # Gives a lot more details at what went wrong (borrowed from Myatus' dialplan)
   sys.Log("** Error: " + $!) unless $!.to_s =~ /Thread was being aborted./
end

MikeTelis
Posts: 1581
Joined: Wed Jul 30, 2008 6:48 am

Re: maybe some one can help me

Post by MikeTelis » Sat Oct 08, 2011 4:08 am

podlinez.net is not resolvable; try changing URI to '6506441934@podlinez.com'.

winter
Posts: 2
Joined: Fri Oct 07, 2011 9:19 pm

Re: maybe some one can help me

Post by winter » Sat Oct 08, 2011 6:33 am

OH MY GOD
thank u i just changed 2 of them to .com and BAM it worked HA HA HA that is toooooo great :)
thank u again

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest