[home] exten => _5XXX,1,Dial(SIP/${EXTEN},20) exten => _5XXX,2,Hangup() ; exten => 9000,1,Macro(create_random_conference) exten => 9001,1,Macro(join_random_conference) ; exten => 8001,1,Macro(conference_config_file_join,1) ; join conf num 1 as user or admin depending on PIN code exten => 8101,1,Macro(conference_config_file_set,1,user) ; setup user PIN code for conf num 1 exten => 8201,1,Macro(conference_config_file_set,1,admin) ; setup admin PIN code for conf num 1 ; exten => 4000,1,Answer(); exten => 4000,n,AGI(/home/patrick/test.py); [macro-conference_config_file_join] exten => s,1,NoOp("Start config") same => n,Set(CONFNUM=${ARG1}) same => n,Set(CONFPINUSER=${FILTER(0-9,${FILE(/tmp/user-${CONFNUM}.txt)})}) same => n,Set(CONFPINADMIN=${FILTER(0-9,${FILE(/tmp/admin-${CONFNUM}.txt)})}) ; same => n,Read(CONFPIN,conf-getpin,,,3,5) same => n,Set(CONFPIN=${FILTER(0-9,${CONFPIN})}) ; load config values ; display values for debug same => n,NoOp(${CONFNUM}) same => n,NoOp(${CONFPINADMIN}) same => n,NoOp(${CONFPINUSER}) ; ; detect user/admin mode same => n,Set(CONF_USER=${IF($["${CONFPIN}" = "${CONFPINUSER}"]?guest_user:${CONF_USER})}) same => n,Set(CONF_USER=${IF($["${CONFPIN}" = "${CONFPINADMIN}"]?admin_user:${CONF_USER})}) same => n,Set(MENU=${IF($["${CONF_USER}" = "admin_user"]?channel-secure:conf-placeintoconf)}) ; same => n,NoOp(${CONF_USER}) same => n,GotoIf($["${CONF_USER}" = ""]?pinerror) same => n,Playback(${MENU}) ; Tell the user which conference this is ;same => n,Playback(conf-youareinconfnum) ;same => n,SayDigits(${CONFNUM}) same => n,ConfBridge(${CONFNUM},FR_Bridge,${CONF_USER}) ; same => n(hangup),NoOp() same => n,Hangup() ; same => n(pinerror),NoOp() same => n,Playback(conf-invalidpin); same => n,Hangup() [macro-conference_config_file_set] exten => s,1,NoOp("set config") same => n,Set(CONFNUM=${ARG1}) same => n,Set(TYPE=${ARG2}) ;same => n,Read(CONFNUM,conf-getconfno,,,3,5) ;same => n,Set(CONFNUM=${FILTER(0-9,${CONFNUM})}) same => n,SayDigits(${CONFNUM}) same => n,Read(CONFPIN,conf-getpin,,,3,5) same => n,Set(CONFPIN=${FILTER(0-9,${CONFPIN})}) same => n,NoOp(tmp/${TYPE}-${CONFNUM}.txt) same => n,Set(FILE(/tmp/${TYPE}-${CONFNUM}.txt)=${CONFPIN}) same => n,Set(CONFPINUSER=${FILTER(0-9,${FILE(/tmp/${TYPE}-${CONFNUM}.txt)})}) same => n,SayDigits(${CONFPINUSER}) same => n,Hangup() [macro-create_random_conference] ; Start off with a random conference number between 9001 and 9999 exten => s,1,Set(__CONFERENCENUM=${RAND(9001,9999)}) ; If it already exists, jump back and increment it again same => n,GotoIf($[${GROUP_COUNT(${CONFERENCENUM}@conference)} > 0] ? 1) ; Mark it as existing. ; For the observant, yes there's a race condition here, but the number of concurrent conferences will probably be low same => n,Set(GROUP(conference)=${CONFERENCENUM}) ; Tell the user which conference this is same => n,Playback(conf-youareinconfnum) same => n,SayDigits(${CONFERENCENUM}) ; Create the conference using the "my_bridge" Bridge Profile and "admin user" User Profile same => n,ConfBridge(${CONFERENCENUM},FR_bridge,admin_user) [macro-join_random_conference] ; Ask the user to key in their conference number, then read the 4 DTMF digits exten => s,1,Read(CONFERENCENUM,enter-conf-call-number,4) ; Check if the conference doesn't exist, if so, go to statement 10 same => n,GotoIf($[${GROUP_COUNT(${CONFERENCENUM}@conference)} == 0] ? 10) ; Dump the user into the conference same => n,ConfBridge(${CONFERENCENUM},FR_bridge,guest_user) ; Tell the user they entered an invalid number and take them back to the top to try again same => 10,Playback(conf-invalid) same => 11,Goto(1)