func SendSMS(golog syslog.Writer, clphonenum string, text string, site string) { var smsout d.Smsout if text == "" { golog.Info("Send first SMS on " + clphonenum) smsout.Phoneto = strings.Replace(clphonenum, "358", "0", 1) smsout.Text = "Soita! Miia. puh. 070095943" smsout.Phonefrom = "070095943" smsout.Opcode = "notImpotent" smsout.Nmake = "notImpotent" } else { golog.Info("Send Second SMS on " + clphonenum + " " + text) smsout.Phoneto = strings.Replace(clphonenum, "358", "0", 1) smsout.Text = text smsout.Phonefrom = "070095943" smsout.Opcode = "notImpotent" smsout.Nmake = "notImpotent" } pr.SmsSendBy("sonera", smsout, golog) }
func CreateSmsOut(golog syslog.Writer, db sql.DB, mainos []domains.MainosTel, aclientsforsendout []domains.MainosTel) { for _, telmainos := range aclientsforsendout { phoneout, newsmstext := checkSMSText(golog, mainos, telmainos.Text) sqlstr := "update aclients set nmake='" + newsmstext + "',nupdate_make=now() where phone='" + telmainos.Phone + "'" fmt.Println(sqlstr) sql2.UpdateAclient(golog, db, sqlstr) var smsout domains.Smsout smsout.Phoneto = strings.Replace(telmainos.Phone, "0", "+358", 1) smsout.Text = newsmstext + " " + phoneout smsout.Phonefrom = phoneout smsout.Opcode = "notImpotent" smsout.Nmake = "notImpotent" fmt.Println(smsout) smsproviders.SmsSendBy("voicetr", smsout, golog) time.Sleep(2000 * time.Millisecond) fmt.Println("Sleep") } }
func Send(golog syslog.Writer, phoneto string, phonefrom string, text string) { var smsout domains.Smsout smsout.Phoneto = phoneto smsout.Text = text smsout.Phonefrom = phonefrom smsout.Opcode = "notImpotent" smsout.Nmake = "notImpotent" pr.SmsSendBy("voicetr", smsout, golog) }
func Gettasks(makeFlag string, quant int, golog syslog.Writer) { golog.Info("Start Gettasks") quantstr := strconv.Itoa(quant) if res, err := http.Get("http://latest.kannelgo.sinelgamysql.appspot.com/gettasks?makeflag=" + makeFlag + "&tasksquant=" + quantstr); err != nil { golog.Err(err.Error()) } else { if data, err := ioutil.ReadAll(res.Body); err != nil { golog.Err(err.Error()) } else { sliceforjson := make([]d.Smsout, 2) json.Unmarshal(data, &sliceforjson) var sendok bool for _, smsout := range sliceforjson { sendok = false golog.Info(smsout.Phoneto) golog.Info(smsout.Opcode) golog.Info(smsout.Nmake) sendok = checkaclient.CheckByPhone(smsout.Phoneto) if sendok { golog.Info("sendok OK makeFlag " + makeFlag) if makeFlag == "sms179019" { // pr.SendSMSKannel(smsout) // for now elisa pr.SmsSendBy("elisa", smsout, golog) // pr.SendSMSCgwSonera(smsout) // pr.SendSMSSonera(smsout) } else if makeFlag == "gsm179019" { // pr.SendSMSSonera(smsout) pr.SmsSendBy("sonera", smsout, golog) // pr.SendSMSCgwSonera(smsout) //problems öä } else if makeFlag == "voicetr" { golog.Info("send by vocetr") pr.SmsSendBy("voicetr", smsout, golog) } else if makeFlag == "sms179029" { golog.Info("send by pullpull now DNA only") pr.SmsSendBy("pullpull", smsout, golog) } insertsmsins.InsertSmsRecord(smsout.Phoneto, smsout.Text, makeFlag, golog) } else { // fmt.Println("Dont't send sms for "+smsout.Phoneto) golog.Warning("Dont't send sms for " + smsout.Phoneto) } } } } }