package action import ( "errors" "fmt" "pbx-api-gin/internal/app/ami" "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 := "Local/0500" //paging pacu action := map[string]string{ "Action": "Originate", "Channel": Chan, "Exten": "000", "CallerID": PaType, "Context": "broadcast-playfile", "Priority": "1", "Variable": Para, } res, _, err := ami.AminInstance.Send(action) if err != nil { return err } if res["Response"] != "Success" { return errors.New(res["Message"]) } return nil }