package action import ( "errors" "fmt" "strings" ) func PlaybackPacu(filename string, count int, delay int, PaType string) (err error) { Para := fmt.Sprintf("count=%d,filename=%s,delay=%d,priority=%s", count, strings.Replace(filename, ".wav", "", -1), delay, PaType) Chan := "" switch PaType { case "STN": Chan = "Local/0503" //spa-rule case "SPC": Chan = "Local/0505" //spc-rule case "DCS": Chan = "Local/0504" //dc-rule case "CHK": Chan = "Local/0503" //paging pacu case "EMG": Chan = "Local/0502" //emg-rule } action := map[string]string{ "Action": "Originate", "Channel": Chan, "Exten": "000", "CallerID": PaType, "Context": "broadcast-playfile", "Priority": "1", "Variable": Para, } res, _, err := AminInstance.Send(action) if err != nil { return err } if res["Response"] != "Success" { return errors.New(res["Message"]) } return nil }