加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

FreeSWITCH 拨号脚本之public.xml

发布时间:2020-12-16 06:21:10 所属栏目:百科 来源:网络整理
导读:#!/usr/bin/lua --Author:jncheng --Version:20150520 --Email:butte@sina.com ---------------------------------------------------------------------------------------- session:setVariable("continue_on_fail","USER_BUSY,NO_ANSWER,TIMEOUT,NO_USER_R
#!/usr/bin/lua --Author:jncheng --Version:20150520 --Email:butte@sina.com ---------------------------------------------------------------------------------------- session:setVariable("continue_on_fail","USER_BUSY,NO_ANSWER,TIMEOUT,NO_USER_RESPONSE") --get the dial extension number exten = session:getVariable("destination_number") exten_len=string.len(exten) fs_ivr_dir = "/usr/local/freeswitch/sounds" cai_lin = fs_ivr_dir.."/ring.wav" session:setVariable("ringback",cai_lin) --session:setVariable("effective_caller_id_name",src_exten) if (exten_len == 4) then --Connect the local MySQL database(DBname,User,Password) --local dbh = freeswitch.Dbh("test","fs","123qwe") --Connect the ODBC DSN Database(odbcsourcename:Username:Passwod),in odbc.ini local dbh = freeswitch.Dbh("odbc://fs:fs:123qwe") assert(dbh:connected()) --Get the SIP User's Dial string dbh:query("select url from registrations where reg_user="..exten,function(row) --freeswitch.consoleLog("NOTICE","------------------------------------------") --freeswitch.consoleLog("NOTICE",string.format("%sn",row.url)) --freeswitch.consoleLog("NOTICE","------------------------------------------") exten_url = string.format("%s",row.url) end); --If the user not registration,answer the call,and tell the user call net called if (exten_url == nil) then session:answer() session:sleep(2000) session:streamFile(fs_ivr_dir.."/dialed_again.wav") session:sleep(2000) session:hangup() else ---define the split string function,to get the dial string.Not write by me,From internet function Split(szFullString,szSeparator) local nFindStartIndex = 1 local nSplitIndex = 1 local nSplitArray = {} while true do local nFindLastIndex = string.find(szFullString,szSeparator,nFindStartIndex) if not nFindLastIndex then nSplitArray[nSplitIndex] = string.sub(szFullString,nFindStartIndex,string.len(szFullString)) break end nSplitArray[nSplitIndex] = string.sub(szFullString,nFindLastIndex - 1) nFindStartIndex = nFindLastIndex + string.len(szSeparator) nSplitIndex = nSplitIndex + 1 end return nSplitArray end local list = Split(exten_url,";") local str_url = list[1] session:execute("bridge",str_url) --Add tell why not scueefull bridge session:answer() local fail_cause=session:getVariable("originate_disposition") session:streamFile(fs_ivr_dir.."/"..fail_cause..".wav") session:sleep(2000) session:hangup() end --if the dial length is not 4,tell check the number else session:answer() session:setVariable("call_time_out","20") session:sleep(2000) session:streamFile(fs_ivr_dir.."/check_number.wav") session:sleep(2000) session:hangup() end

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读