func BlockedFromPSTN(sess *agi.Session) { dbinfo := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=%s", DBHost, DBPort, DBUser, DBPass, DBName, DBSSL) db, err := sql.Open(DBType, dbinfo) if err != nil { LoggerErr(err) } rows, err := db.Query(fmt.Sprintf(BLOCKPSTNQUERY, sess.Env["callerid"])) if err != nil { LoggerErr(err) } defer rows.Close() var arg1, arg2 string for rows.Next() { rows.Scan(&arg1, &arg2) } db.Close() if len(arg1) != 0 && len(arg2) != 0 { _, err := sess.Exec("UserEvent", fmt.Sprintf(UEBLOCKEDABON, sess.Env["callerid"], sess.Env["uniqueid"])) if err != nil { LoggerErr(err) } sess.Hangup() } }
func FaxRecv(sess *agi.Session) { sess.Answer() uid := strings.Split(sess.Env["uniqueid"], ".") _, err := sess.SetVariable("FAXFILENAME", fmt.Sprintf("%s_%s_%s", sess.Env["callerid"], sess.Env["dnid"], uid[0])) _, err = sess.SetVariable("FAXOPT(headerinfo)", fmt.Sprintf("Received_by_%s_%s", sess.Env["callerid"], uid[0])) _, err = sess.SetVariable("FAXOPT(localstationid)", sess.Env["callerid"]) _, err = sess.SetVariable("FAXOPT(maxrate)", "14400") _, err = sess.SetVariable("FAXOPT(minrate)", "4800") filename, err := sess.GetVariable("FAXFILENAME") _, err = sess.Exec("ReceiveFax", fmt.Sprintf(FAXDIR+FAXRECVSTR, filename.Dat)) if err != nil { LoggerErr(err) } else { fs, err := sess.GetVariable("FAXSTATUS") fp, err := sess.GetVariable("FAXPAGES") fb, err := sess.GetVariable("FAXBITRATE") fr, err := sess.GetVariable("FAXRESOLUTION") if err != nil { LoggerErr(err) } if fs.Dat == "" || fs.Dat == "FAILED" { fs.Dat = "FAILED" } msg := fmt.Sprintf("Статус: %s\nС номера: %s\nНа номер: %s\nКоличество страниц: %s\nСкорость передачи(bitrate): %s\nРазрешение файла: %s", fs.Dat, sess.Env["callerid"], sess.Env["dnid"], fp.Dat, fb.Dat, fr.Dat) NotifyMail("ФаксВходящий", sess.Env["callerid"], msg, MAIL) NotifyMail("ФаксВходящий", sess.Env["callerid"], msg, "fax-"+sess.Env["dnid"]) } sess.Hangup() }
func Gegensprechanlage(sess *agi.Session) { tf := timeFormat2() rf := fmt.Sprintf("%s%s_%s_%s%s", DFVAR0[0], tf, sess.Env[DFVAR1[0]], sess.Env[DFVAR1[1]], DFVAR0[1]) _, err := sess.Exec(DFVAR2, rf) if err != nil { LoggerErr(err) } }
func eBackground(sess *agi.Session, dir string, phrases []string) { for _, phrase := range phrases { sess.Verbose("Phrase: " + phrase) _, err := sess.Exec("Background", fmt.Sprintf("%s%s", dir, phrase)) if err != nil { LoggerErr(err) } } }
func ConfBridgeConfs(sess *agi.Session) { _, err := sess.Exec("DumpChan", "255") if err != nil { LoggerErr(err) } _, err = sess.SetVariable("__CONFNO", sess.Env["extension"]) if err != nil { LoggerErr(err) } _, err = sess.Exec("ConfBridge", fmt.Sprintf("%s,,,%s", sess.Env["extension"], UMENU)) if err != nil { LoggerErr(err) } LoggerString("Confbridge Admin add " + sess.Env["extension"]) }
func SetNY(sess *agi.Session) { NYG = arrayShuffle(NYG) f := strings.Split(NYG[0], ".") find := false for _, g := range f { if g == NYVAR1 { find = true } } if find == true { _, err := sess.Exec(NYVAR2, fmt.Sprintf("%s%s", NYVAR0[1], f[0])) if err != nil { LoggerErr(err) } } }
func ConfBridgeAccess(sess *agi.Session) { sess.Answer() _, err := sess.SetVariable("__CONFNO", sess.Env["extension"]) if err != nil { LoggerErr(err) } _, err = sess.SetVariable("__DYNAMIC_FEATURES", CONFBRIDGE_FEATURES) if err != nil { LoggerErr(err) } if sess.Env["extension"] == sess.Env["callerid"] { inner_num, err := strconv.Atoi(LEN_INNER_NUM) if len(sess.Env["callerid"]) == inner_num { _, err = sess.Exec("ConfBridge", fmt.Sprintf("%s,,,%s", sess.Env["extension"], AMENU)) } else { _, err = sess.Exec("ConfBridge", fmt.Sprintf("%s,,,%s", sess.Env["extension"], UMENU)) } if err != nil { LoggerErr(err) } } else { _, err = sess.Exec("ConfBridge", fmt.Sprintf("%s,,,%s", sess.Env["extension"], UMENU)) } if err != nil { LoggerErr(err) } LoggerString("Confbridge Admin " + sess.Env["extension"]) }