本文整理汇总了Golang中github.com/zaf/agi.Session.Exec方法的典型用法代码示例。如果您正苦于以下问题:Golang Session.Exec方法的具体用法?Golang Session.Exec怎么用?Golang Session.Exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/zaf/agi.Session
的用法示例。
在下文中一共展示了Session.Exec方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: BlockedFromPSTN
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()
}
}
示例2: FaxRecv
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()
}
示例3: Gegensprechanlage
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)
}
}
示例4: eBackground
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)
}
}
}
示例5: ConfBridgeConfs
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"])
}
示例6: SetNY
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)
}
}
}
示例7: ConfBridgeAccess
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"])
}