Макроc переадресации:
Работает при выставление времени в 0 как безусловная.
Если время не 0 то по не ответу.
[macro-redirect-time]
exten => s,1,NoOp(CHANNEL(from):${CHANNEL(from)})
same => n,MYSQL(Connect connid localhost user pass db)
same => n,MYSQL(Query resultid ${connid} SELECT `r_callerid`,`r_number`,`r_time` FROM `redirect` WHERE client = '${CUT(ARG1,_,2)}' AND r_callerid = '${ARG2}')
same => n,MYSQL(Fetch fetchid ${resultid} r_callerid r_number r_time)
same => n,MYSQL(Clear ${resultid})
same => n,MYSQL(Disconnect ${connid})
same => n,GotoIf($["${r_number}" = ""]?rtime)
same => n,GotoIf($["${r_time}" = "0"]?redir:rtime)
same => n(rtime),NoOp(Mark RTIME)Вызывается exten => _XXX,n,Macro(redirect-time,${CONTEXT},${EXTEN})
same => n,Dial(SIP/${CUT(ARG1,_,2)}${ARG2},${r_time},Tt)
same => n,GotoIf($["${r_time}" = ""]?exit)
same => n,GotoIf($["${r_time}" = "0"]?exit)
same => n(redir),NoOp(Mark REDIR)
same => n,Dial(Local/${r_number}@${ARG1})
same => n(exit),MacroExit
База в MySQL:
CREATE TABLE `redirect` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`r_callerid` decimal(3,0) DEFAULT '0',
`r_number` decimal(11,0) DEFAULT '0',
`r_time` decimal(3,0) NOT NULL DEFAULT '120',
`client` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8