Mijn dialplan bij MySIPSwitch

Nederlands Forum
User avatar
TheFug
Posts: 914
Joined: Sat Oct 06, 2007 8:23 am
Location: The Netherlands, North-Holland

Post by TheFug » Wed Oct 01, 2008 3:44 pm

Je kunt misschien aan Guilliame, of Aaron vragen, om je huidige normale dialplan, om te zetten, dan heb je een begin, zo heb ik het ook gedaan,
of je moet even uitleggen, wat precies de bedoeling is, als je dialplan niet al te ingewikkeld is, wil ik het ook wel voor je proberen.
Thanks, The Fug.

gear: my ISP's Zyxel Modem/Router in bridge, Sitecom WL309 Router, Siemens Gigaset 301D

Myatus
Posts: 30
Joined: Wed Sep 24, 2008 12:49 pm
Location: London, UK

Post by Myatus » Wed Oct 01, 2008 8:22 pm

Als die dial plan niet in NL werkt, laat mij dan even weten wat het probleem is. Dan pas ik dat wel even aan - 't idee is voor een "universal" dial plan :)

jvwelzen
Posts: 716
Joined: Thu Sep 11, 2008 1:56 pm

Post by jvwelzen » Thu Oct 02, 2008 3:13 pm

Mijn aangepaste dialplan van Mike voor mijn locale versie van mysipswitch

Opmerking :

Ik gebruik bijv 112@budgetphone-#{sys.Username}",

Om zo niet iedere keer het script te hoeven aanpassen voor ieder user
In mijn locale versie komt het telefoon nummer en gebruikers naam overeen...


#Ruby

# Speed dial entries. Format: "key" => "number"

Speeddial = {

'112' => "112@budgetphone-#{sys.Username}",
'303' => '303@sip.blueface.ie', # Blueface speaking clock.
'612' => '612@fwd.pulver.com', # FWD speaking clock.
'613' => '613@ixcall.net', # IXCall Echo Test.
'1233' => "0207173777@budgetphone-#{sys.Username}" # Budgetphone Voicemail.

}

# Providers: "key" => "template". Template format: prefix@Provider

VSPtab = {
'0' => "@ intervoip-#{sys.Username}", # Future-nine default route
'2' => '02 @ F9', # Future-nine grey route (Not Used)
'3' => '03 @ F9', # Future-nine white route (Not Used)
'4' => '04 @ F9', # Future-nine premium route (Not Used)
'7' => '@ Globe7', # Globe7 (Not Used)
'8' => '@ Voxalot', # Voxalot (Not Used)
'9' => "@ poivy-#{sys.Username}", # Poivy 0800 Numbers

}

# ******************** s e l e c t V S P *******************************

def selectVSP # VoIP provider selection
case @num

when /^31800/ # 0800 Toll free Netherlands
route(9,"Call to Poivy for Free 0800 Numbers")

when /^31/ # Local Call, 31 Netherlands
route(0,"Destination - NL 31 Netherlands")

when /(^0([2-9]\d\d)\d{7,7})/ # Netherlands
@num = $1 # ignore everything after 7-dig phone number
case $2 # check area code
when "800" # toll free numbers...
route(9,"Destination - NL toll free Trough Poivy")
else
route(0,"Destination - Netherlands Intervoip")
end

else
route(0,"Default route applied")
end
end

# ************************** C A L L S W I T C H **********************

def callswitch(num,*args)
route # Initialize vars

@num = num unless @num = Speeddial[num] # If there is speed dial entry for it...

unless @num =~ /@/ # If we already have URI, skip all number processing
@num.gsub!(/%(..)/) {$1.to_i(16).chr} # Convert %hh into ASCII

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)

unless @num.sub!(/^(\+|00)/,'') # If no international prefix, process special cases below
case @num

when /^0/
@num[0] = '31' # Replace 0 Local call to 31 for the Netherlands

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?

# Invoke selectVSP prior to ENUM lookup just in case we need to modify @num

route # re-initialize variables
selectVSP # Pick appropriate provider for the call

if enumuri = sys.ENUMLookup("+#{@num}.e164.org") # Check if NAPTR exists for the number
sys.Log("ENUM entry found: '#{enumuri}'") # If yes, call that URI
req.Header.From.FromName = "#{sys.Username}" # Send CallerID (I use Voip Number also as username)
sys.Dial(enumuri) # if call failed, call via regular VSP.
status() # If this is not what you want, add "return"
sys.Log("Call to #{enumuri} failed (#{@reason}), will call again via regular VoIP provider")
end

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
@num = tpl.sub(/\s*@\s*/) {|x| @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}")
sys.Respond(@code,@reason) # Forward error code to ATA
end

# ****************************** R O U T E *******************************

def route(p='', l='')
@p = p; @l = l
end

# ***************************** S T A T U S ******************************

def status
if (ptr = sys.LastDialled[0]).nil?
@code = 487; @reason = 'Cancelled by Huizen Wireless'
else
ptr = ptr.TransactionFinalResponse
@code = ptr.StatusCode; @reason = ptr.ReasonPhrase
# sys.Log("#{ptr.ToString()}")
end
end

# ******************************* M A I N ********************************

sys.Log("** Call from #{req.Header.From.ToString()} to #{req.URI.User} **")

t = Time.now + (0*60*60) # Get current time and adjust to local (GMT+1)
sys.Log(t.strftime('Local time: %c'))

if sys.In # If incoming call...
name = req.Header.From.FromName.to_s # create a copy of FromName

# if FromName isn't empty and isn't all digits (caller's phone #)
# replace it with username from caller's URI

name = req.Header.from.FromURI.User.to_s if name =~ /^$|\D/

# Prefix 10-digit numbers with "1" (US country code).
# Some DIDs send Caller ID without country code
# Change FromURI.User, too - or else Bria won't find contact in its phonebook!

req.Header.from.FromURI.User = name = ('1' + name) if name =~ /^[2-9]\d{9,9}$/

sys.Log("FromName: '#{name}'")
req.Header.From.FromName = name # Set FromName for sys.Dial

# if sys.IsAvailable() # If my ATA is registered (doesn't work with my Fritzbox)
sys.Dial("#{sys.Username}@sip.huizenwireless.nl") # forward all incoming calls to it

# elsif (8..23) === t.hour # else forward calls to my home or mobile phone
# sys.Log("#{sys.Username} is not online, forwarding call to Voicemail...")
# end

sys.Respond(480, "#{sys.Username} Not online")


else # Outbound call ...
callswitch(req.URI.User.to_s)
end


Dan heb ik nog een klein vraagje

Als ik met mijn mobiel naar budgetphone bel ga ik na 35 seconden naar de voicemail

Alleen als ik via een enumlookup belt niet nou dacht ik daar een oplossing voor te hebben maar dit werkt dus niet

Dit had ik in gedachten

# if sys.IsAvailable() # If my ATA is registered (doesn't work with my Fritzbox)
sys.Dial("#{sys.Username}@sip.huizenwireless.nl", 30) # forward all incoming calls to it
sys.Dial("03571100000@budgetphone-#{sys.Username}")

# elsif (8..23) === t.hour # else forward calls to my home or mobile phone
# sys.Log("#{sys.Username} is not online, forwarding call to Voicemail...")
# end

Of dit is misschien wat duidelijker

# if sys.IsAvailable() # If my ATA is registered (doesn't work with my Fritzbox)
sys.Dial("#{sys.Username}@sip.huizenwireless.nl", 30) # forward all incoming calls to it
sys.Dial("03571100000@budgetphone-313571100000")

# elsif (8..23) === t.hour # else forward calls to my home or mobile phone
# sys.Log("#{sys.Username} is not online, forwarding call to Voicemail...")
# end

sys.Respond(480, "#{sys.Username} Not online")

Post Reply