当前位置: 首页>>代码示例>>Golang>>正文


Golang Session.SetVariable方法代码示例

本文整理汇总了Golang中github.com/zaf/agi.Session.SetVariable方法的典型用法代码示例。如果您正苦于以下问题:Golang Session.SetVariable方法的具体用法?Golang Session.SetVariable怎么用?Golang Session.SetVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/zaf/agi.Session的用法示例。


在下文中一共展示了Session.SetVariable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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()
}
开发者ID:yosh0,项目名称:agiserver,代码行数:35,代码来源:AGIServer.go

示例2: 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"])
}
开发者ID:yosh0,项目名称:agiserver,代码行数:28,代码来源:AGIServer.go

示例3: 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"])
}
开发者ID:yosh0,项目名称:agiserver,代码行数:15,代码来源:AGIServer.go

示例4: InboundCall

func InboundCall(sess *agi.Session) {
	//	LoggerString("INCOMING NUM    " + sess.Env["callerid"])
	rex, err := regexp.Compile(`^[7|8](\d{10})$`)
	res := rex.FindStringSubmatch(sess.Env["callerid"])
	if res != nil {
		LoggerString("RES NOT NIL " + sess.Env["callerid"])
		_, err := sess.SetVariable("CALLERID(num)", res[1])
		if err != nil {
			LoggerErr(err)
		} else {
			LoggerString("NUM CHANGED TO  " + res[1])
		}
		_, err = sess.SetVariable("CALLERID(name)", res[1])
		if err != nil {
			LoggerErr(err)
		}
	} else {
		//		LoggerString("NUM NOT CHANGED " + sess.Env["callerid"])
	}
	if err != nil {
		LoggerErr(err)
	}
	rex2, err := regexp.Compile(`^([a|A]nonymous|unknown)$`)
	res2 := rex2.FindStringSubmatch(sess.Env["calleridname"])
	if res2 != nil {
		LoggerString("RES2 " + res2[1])
		_, err := sess.SetVariable("CALLERID(name)", "0")
		if err != nil {
			LoggerErr(err)
		} else {
			LoggerString("NAME CHANGED TO 0")
		}
	}
	rex3, err := regexp.Compile(`^([a|A]nonymous|unknown)$`)
	res3 := rex3.FindStringSubmatch(sess.Env["callerid"])
	if res3 != nil {
		LoggerString("RES3 " + res3[1])
		_, err := sess.SetVariable("CALLERID(num)", "0")
		if err != nil {
			LoggerErr(err)
		} else {
			LoggerString("NUM CHANGED TO 0")
		}
	}
}
开发者ID:yosh0,项目名称:agiserver,代码行数:45,代码来源:AGIServer.go

示例5: CustomerCheck

func CustomerCheck(sess *agi.Session, cc string) {
	CSTMR := make(map[int][]map[string]string)
	customer, err := CustomerGet(sess, cc)
	if err != nil {
		fmt.Println(err.Error())
	} else {
		i := 0
		for _, cust := range customer {
			cstmr := make(map[string]string)
			if cust.Var6 == "2" && cust.Var3 == "0" {
				if sess.Env[CUSTVARC0] != cust.Var7[1:] {
					LoggerString(fmt.Sprintf("%s != %s %s", sess.Env[CUSTVARC0], cust.Var7[1:], "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"))
				}
				cstmr[CUSTVARR0[0]] = cust.Var0
				cstmr[CUSTVARR1[0]] = cust.Var1
				cstmr[CUSTVARR2[0]] = cust.Var2
				cstmr[CUSTVARR3[0]] = cust.Var3
				cstmr[CUSTVARR4[0]] = cust.Var4
				cstmr[CUSTVARR5[0]] = cust.Var5
				cstmr[CUSTVARR6[0]] = cust.Var6
				cstmr[CUSTVARR7[0]] = cust.Var7
				cstmr[CUSTVARR8[0]] = cust.Var8
				LoggerString("\n" +
					CUSTVARC0 + " " + sess.Env[CUSTVARC0] + "\n" +
					CUSTVARR0[0] + " " + cust.Var0 + "\n" +
					CUSTVARR1[0] + " " + cust.Var1 + "\n" +
					CUSTVARR2[0] + " " + cust.Var2 + "\n" +
					CUSTVARR3[0] + " " + cust.Var3 + "\n" +
					CUSTVARR4[0] + " " + cust.Var4 + "\n" +
					CUSTVARR5[0] + " " + cust.Var5 + "\n" +
					CUSTVARR6[0] + " " + cust.Var6 + "\n" +
					CUSTVARR7[0] + " " + cust.Var7[1:] + "\n" +
					CUSTVARR8[0] + " " + cust.Var8 + "\n")
				CSTMR[i] = append(CSTMR[i], cstmr)
				i++
			}
		}
		ii := strconv.Itoa(i)
		if i == 1 {
			/*
				_, err := sess.SetVariable(CUSTVARA0, ii)
			*/

			_, err = sess.SetVariable(CUSTVARA1, CSTMR[0][0][CUSTVARR1[0]])
			/*
				_, err = sess.SetVariable(CUSTVARA2, CSTMR[0][0][CUSTVARR2[0]])
				_, err = sess.SetVariable(CUSTVARA5, CSTMR[0][0][CUSTVARR5[0]])
			*/
			if err != nil {
				LoggerErr(err)
			}
			LoggerString("\n===================================================\n" +
				CUSTVARA0 + " " + ii + "\n" +
				CUSTVARA1 + " " + CSTMR[0][0][CUSTVARR1[0]] + "\n" +
				CUSTVARA2 + " " + CSTMR[0][0][CUSTVARR2[0]] + "\n" +
				CUSTVARA5 + " " + CSTMR[0][0][CUSTVARR5[0]] + "\n" +
				CUSTVARR0[0] + " Count: " + ii + "\n" +
				"===================================================\n")
		} else if i > 1 {
			/*
				_, err := sess.SetVariable(CUSTVARA0, ii)
				if err != nil {
					LoggerErr(err)
				}
			*/
			LoggerString("\n===================================================\n")
			LoggerString(CUSTVARA0 + " " + ii)
			/*
			   			for _, vr := range CSTMR {
			   				LoggerString("++++++!!!!!!!!!!!!!!!!")
			   //				LoggerMap2(vr)

			   				if vr[0][CUSTVARR5[0]] == "1" {
			   					LoggerString(vr[0][CUSTVARR5[0]])
			   					_, err = sess.SetVariable(CUSTVARA5, CSTMR[0][0][CUSTVARR5[0]])
			   					if err != nil {
			   						LoggerErr(err)
			   					}
			   				}

			   				LoggerString("++++++!!!!!!!!!!!!!!!!")
			   			}
			*/
			LoggerString(CUSTVARR0[0] + " Count: " + ii + "\n" +
				"===================================================\n")
		} else {
			LoggerString("\n===================================================\n" +
				CUSTVARC0 + " " + sess.Env[CUSTVARC0] + "\n" +
				CUSTVARR0[0] + " Count: " + ii + "\n" +
				"===================================================\n")
			/*
				_, err = sess.SetVariable(CUSTVARA0, "0")
			*/
			_, err = sess.SetVariable(CUSTVARA1, "0")
			/*
				_, err = sess.SetVariable(CUSTVARA2, "N")
				_, err = sess.SetVariable(CUSTVARA5, "N")
			*/
			if err != nil {
				LoggerErr(err)
//.........这里部分代码省略.........
开发者ID:yosh0,项目名称:agiserver,代码行数:101,代码来源:AGIServer.go


注:本文中的github.com/zaf/agi.Session.SetVariable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。