Esempio n. 1
0
func main() {

	fmt.Println("Start mailagent")

	user := flag.String("user", "", "Smtp user")
	pass := flag.String("pass", "", "Smtp password")
	timer := flag.Int("timer", 5, "timer in minutes")

	cfg := common.NewConfig()
	delay := time.Duration(*timer) * time.Minute

	db := common.NewDbClient(cfg.Service.Redis)

	if *user == "" || *pass == "" {
		fmt.Println("No user or password")
		return
	}

	execMe := func() {
		incomingFile := dumpIncoming(db)
		//acceptedFile := dumpAccepted(db)
		defer os.Remove(incomingFile)
		//		defer os.Remove(acceptedFile)

		md5Hash, err := ComputeMd5(incomingFile)
		if err == nil {
			if md5Hash != "" && prevMd5Hash == md5Hash {
				common.Trace.Println("Ignore sendign file. hashes the same: " + md5Hash)
				return
			}
			prevMd5Hash = md5Hash
		}
		err = sendEmail(*user, *pass, incomingFile /*, acceptedFile*/)
		if err != nil {
			fmt.Println("Send message error", err)
			return
		}
	}

	execMe()

	ticker := time.NewTicker(delay)
	go func() {
		for {
			select {
			case <-ticker.C:
				execMe()
			}
		}
	}()

	fmt.Println("press Ctrl+C")
	common.WaitCtrlC()

	ticker.Stop()
}
Esempio n. 2
0
func main() {
	common.Info.Println("Opencell billing")
	webserver := OpencellWebServer{}
	webserver.Start()
	callListener := BillingListener{}
	go func() {
		callListener.Subscribe()
	}()
	go func() {
		callListener.SubscribeCallerList()
	}()
	common.WaitCtrlC()
}
Esempio n. 3
0
func main() {

	conference := Conference{}

	webServer := WebServer{callback: conference}
	webServer.Start()

	conference.RegisterNumber()

	conference.Subscribe()

	common.WaitCtrlC()
	common.Info.Println("Finished")
}
Esempio n. 4
0
func main() {
	common.Info.Println("Drop conference")

	conference := Conference{}

	participants := conference.GetParticipants()

	common.Info.Println("Participants count", len(participants))

	participants = conference.Drop()

	conference.NotifySms(participants)

	common.Info.Println("Press Ctrl+C")

	common.WaitCtrlC()
}
Esempio n. 5
0
func main() {

	webServer := NewWebServer()
	webServer.Start()

	conference := Conference{}

	participants := conference.GetParticipants()

	conference.Drop()

	for _, participant := range participants {

		call := NewAdvertisingCall(participant)
		call.Prompt(cfg.Messages.Question)

		call.Variant("1").Text(cfg.Messages.Answer1).Confirmation(cfg.Messages.ThanksForAnswer)
		call.Other().Text(cfg.Messages.ThanksForAttention)
		call.Exec()
	}

	common.WaitCtrlC()
}
Esempio n. 6
0
func (sms *PerfTest) Await() {
	common.Info.Println("wait for ctrl+c")
	common.WaitCtrlC()
}
Esempio n. 7
0
func (sms Sms) Await() {
	common.Info.Println("wait for ctrl+c")
	common.WaitCtrlC()
}