Code: Select all
#Ruby
#sys.Trace=true # Remove hash in front sys.Trace to get trace reports
sys.Log("call received on #{req.URI.ToString()} from #{req.Header.From.FromURI.ToString()} at #{Time.now}.")
if sys.Out then
sys.Log("Outgoing call from user domain=#{sys.FromDomain}.")
case req.URI.User
when /^(1800|1866|1877)/ then sys.Dial("*${dst}@SIPHAPPENS") # detects US toll free numbers
when /^00498/ then sys.Dial("275498${dst:5}@BRUJULA") # for testing german toll free number via SipBroker (peering)
when /^06/ then sys.Dial("00316${dst:2}@INTERVOIP") # dials all Dutch mobile numbers with Intervoip
when /^1777/ then sys.Dial("CALLCENTRIC") # detects and dials other Callcentric users
when /^\*75/ then sys.Dial("*75${dst:3}@CALLCENTRIC") # detects and dials Callcentric preset numbers
# Following are prefixes to force the use of an certain provider
when /^\*1/ then sys.Dial("${dst:2}@BRUJULA")
when /^\*2/ then sys.Dial("${dst:2}@SIPGATE")
when /^\*3/ then sys.Dial("${dst:2}@ORBTALK")
when /^\*4/ then sys.Dial("${dst:2}@FWD")
when /^\*5/ then sys.Dial("${dst:2}@IXCALL")
when /^\*6/ then sys.Dial("${dst:2}@VOXALOT")
when /^\*7/ then sys.Dial("${dst:2}@CALLCENTRIC")
when /^\*8/ then sys.Dial("${dst:2}@SIPBROKER")
end
else
sys.Log("Incoming call to domain=#{sys.ToDomain} from host #{req.Header.From.FromURI.Host}.")
if sys.IsAvailable() then
sys.Log("#{sys.Username} is online.")
# will devert calls when my MSS account is offline, to my cellphone
sys.Dial("#{sys.Username}@local&00316xxxxxxxx@INTERVOIP")
else
sys.Log("#{sys.Username} is not online.")
sys.Respond(480, "#{sys.Username} Not online")
end
end
sys.Log will send text or values to monitor screen log,
req.header, will read out string values, from incoming call en will be used in the dialplan handling.
I guess sys.Dial("#{sys.Username}@local") and before that: if sys.in
will do also do the trick to receive incoming calls.
I only don't know, how much the callee will see of the sys.Log from my side...
Sometimes i use the sys.Trace=true function to trace the SIP communication, for all dial rules, i miss the "selective" use per dialrule out of the normal dialplan syntax, i guess something like a subroutine function, like you have in Basic, would be nice too in Ruby...
And an interactive function between IP-phone display and dialplan would be nice too.(if that's possible at all)
btw. the first Brujula dial rule was more of a test to peer/dial to a German free info railway phone number.
The first two Callcentric rules are for dialing an other user, and the second one, to dial Callcentric personal preset(s)
Any incoming internet call will also ring my mobile phone, at costs of InterVOIP