Notice that you need to include the zero, for the morning hours below 10 o ' clock because of the 24 hour clock use. (H%) (in uppercase makes the difference, i guess)
- Code: Select all
#Ruby
sys.Trace=true # when needed to sip trace
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}.")
# my outgoing call detection section
case req.URI.User
when /^(100$|101$|102$|103$)/ then sys.Dial("HUIZENW") # speeddials of HuizenWireless
when /^(8$|613$|612$|958|615$)/ then sys.Dial("BRUJULA") # some speed dials for Brujula
when /^00498/ then sys.Dial("275498${dst:5}@BRUJULA") # dials German tollfree numbers
# when /^0031/ then sys.Dial("${dst}@CALLCENTRIC") # dials Dutch national numbers
when /^900/ then sys.Dial("${dst}@TPAD") # selects Tpad for international numbers
when /^0900/ then sys.Dial("90900${dst:4}@TPAD") # dials Dutch pay info numbers
when /^121/ then sys.Dial("121@TPAD") # Tpad voicemail
when /^0018/ then sys.Dial("${dst:2}@SIPHAPPENS") # dials US tollfree numbers
when /^555/ then sys.Dial("613@BRUJULA") # Brujula echo test
when /^(0044800|0018|0044500|0044808|0049800|0049130|0047800)/ then sys.Dial("${dst}@SIPHAPPENS") # dials various tollfree numbers with siphappens
when /^06/ then sys.Dial("900316${dst:2}@TPAD") # directs outgoing mobilephone calls
when /^080/ then sys.Dial("00318${dst:2}@HUIZENW")
when /^(01|02|03|04|05|07|08)/ then sys.Dial("0031${dst:1}@CALLCENTRIC") # dials Dutch landline numbers
when /^(883|882)/ then sys.Dial("${dst}@VOXALOT") #detects iNUM/eNUM & dials with Voxalot
when /^(00883|00882)/ then sys.Dial("${dst:2}@VOXALOT") #detects iNUM/eNUM & dials with Voxalot
when /^1777/ then sys.Dial("CALLCENTRIC") # dials to other Callcentric users
when /^\*123/ then sys.Dial("${dst}@CALLCENTRIC") # Callcentric voice mail
when /^\*75/ then sys.Dial("CALLCENTRIC") # Dials the Callcentric speeddials
when /^(600|500)/ then sys.Dial("*${dst}@VOXALOT") # speed dials Voxalot
# my speeddial section
when /^\*1/ then sys.Dial("${dst:2}@BRUJULA")
when /^\*2/ then sys.Dial("${dst:2}@BUDGET")
when /^\*3/ then sys.Dial("${dst:2}@HUIZENW")
when /^\*6/ then sys.Dial("${dst:2}@VOXALOT")
when /^\*7/ then sys.Dial("${dst:2}@CALLCENTRIC")
when /^\*8/ then sys.Dial("${dst:2}@SIPBROKER")
when /^\*9/ then sys.Dial("${dst:2}@TPAD")
when /^\*0/ then sys.Dial("${dst:2}@SIPHAPPENS")
end
# my incoming call section
else
sys.Log("Incoming call to domain=#{sys.ToDomain} from host #{req.Header.From.FromURI.Host}.")
t = Time.now + (1*60*60) # Get current time and adjust to local time GMT+1 no DST needed
sys.Log(t.strftime('local time time: %c'))
tijd = t.strftime('%H:%M')
sys.Log("Tijd : #{tijd}")
if (1..5) === t.wday && ('06:35'..'17:15') === tijd # next lines will be executed when this condition is valid
sys.Dial("900316xxxxxxxx@TPAD" ,25)
sys.Dial("9003120xxxxxxx@TPAD")
end
#for all other calls outside the above time and days calls go to MSS registered phone at home
if sys.IsAvailable() then
sys.Log("FromHost: '#{req.Header.from.FromURI.Host}'")
sys.Log("FromUser: '#{req.Header.from.FromURI.User}'")
sys.Log("FromName: '#{req.Header.From.FromName}'")
sys.Log("#{sys.Username} is online.")
sys.Dial("#{sys.Username}@local")
else
sys.Log("#{sys.Username} is not online.")
sys.Log("FromHost: '#{req.Header.from.FromURI.Host}'")
sys.Log("FromUser2: '#{req.Header.from.FromURI.User}'")
sys.Log("FromName2: '#{req.Header.From.FromName}'")
# when offline calls routed to cellphone
sys.Dial("00316xxxxxxxx@CALLCENTRIC")
#sys.Respond(480, "#{sys.Username} Not online")
end
end
