回複:要不貼回到mitbbs?或許混點偽幣

來源: landsend 2009-11-17 21:50:25 [] [博客] [舊帖] [給我悄悄話] 本文已被閱讀: 次 (2642 bytes)
回答: 請版主更新或刪除我在精華區的貼landsend2009-11-17 14:08:07
我用這個dial plan作為in plan就可以了. 我也是從網上copy and paste的, 略做了小修改. 如果哪位對語法領悟得好, 也許可以把這段代碼修改得更精練.

# ******************************* D I A L ********************************

# ******************************* M A I N ********************************
begin
sys.Log("** Call from #{req.Header.From.ToString()} to #{req.URI.User} **")

t = Time.now + ((Tz+8)*60*60) # Get current time and adjust to local. 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 a copy of caller's number

# Prefix 10-digit numbers with "1" (US country code).
# Some DID send Caller ID without country code

name = ('1' + name) if name =~ /^[2-9]\d\d[2-9]\d{6}$/

name.sub!(/^011/,'') # Remove 011 prefix added by Google Voice

sys.Log("FromName: '#{name}'")
req.Header.From.FromName = name # Set FromName for sys.Dial
# Change FromURI.User, too - or else Bria won't find contact in its phonebook!
req.Header.from.FromURI.User = name

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

if sys.IsAvailable() # If my ATA is registered
callswitch("#{sys.Username}@local") # forward all incoming calls to it
elsif (8..23) === t.hour # else forward calls to my home
sys.Log("#{sys.Username} is not online, forwarding call to home number...")
callswitch("0",35) # Note that '0' is in my speed dial list
end

sys.Respond(480, "#{sys.Username} Not online") # switch to voice mail

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.find {|x| x == 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
請您先登陸,再發跟帖!

發現Adblock插件

如要繼續瀏覽
請支持本站 請務必在本站關閉/移除任何Adblock

關閉Adblock後 請點擊

請參考如何關閉Adblock/Adblock plus

安裝Adblock plus用戶請點擊瀏覽器圖標
選擇“Disable on www.wenxuecity.com”

安裝Adblock用戶請點擊圖標
選擇“don't run on pages on this domain”