Exemplo n.º 1
0
func Display(noti_msg IrcNotify, linger int64, quiet bool) {
	if !quiet {
		log.Printf("%#v", noti_msg)
	}
	if ShouldIgnore(noti_msg.Channel) {
		if !quiet {
			log.Printf("Ignoring: %s", noti_msg.Channel)
		}
		return
	}
	hello := notify.NotificationNew(noti_msg.Server+","+noti_msg.Channel,
		noti_msg.Message,
		"")

	if hello == nil {
		log.Println("ERROR: Unable to create a new notification")
		return
	}
	notify.NotificationSetTimeout(hello, 0)

	if e := notify.NotificationShow(hello); e != nil && len(e.Message()) > 0 {
		log.Printf("ERROR: %s", e.Message())
		return
	}
	time.Sleep(time.Duration(linger) * time.Second)
	notify.NotificationClose(hello)
}
Exemplo n.º 2
0
func main() {
	notify.Init("Hello World!")
	hello := notify.NotificationNew("Hello World!",
		"This is an example notification.",
		"")

	if hello == nil {
		fmt.Fprintf(os.Stderr, "Unable to create a new notification\n")
		return
	}
	// hello.SetTimeout(3000)
	notify.NotificationSetTimeout(hello, DELAY)

	// hello.Show()
	if e := notify.NotificationShow(hello); e != nil {
		fmt.Fprintf(os.Stderr, "%s\n", e.Message())
		return
	}

	time.Sleep(DELAY * 1000000)
	// hello.Close()
	notify.NotificationClose(hello)

	notify.UnInit()
}
Exemplo n.º 3
0
func main() {
	file, err := os.Open("config.json")

	if err != nil {
		fmt.Println("Couldn`t read config file, stopping program.")
		panic(err)
	}

	decoder := json.NewDecoder(file)
	config := &Config{}
	decoder.Decode(&config)

	sigChan := make(chan os.Signal, 1)

	signal.Notify(sigChan, os.Interrupt)
	signal.Notify(sigChan, syscall.SIGTERM)
	signal.Notify(sigChan, syscall.SIGKILL)

	go func() {
		sigVal := <-sigChan
		cleanExit(sigVal)
	}()

	notify.Init("Nora")
	for {
		if IfFile(config.File) == false {
			time.Sleep(DELAY * time.Second)
			note := notify.NotificationNew("Message from Norad", "Vezi ca mor", "")
			go sendNote(note)
			time.Sleep(DELAY * 5 * time.Second)
			os.Exit(1)
			fmt.Printf("Am murit.") //doesn`t matter what you do after this point
		} else {
			time.Sleep(DELAY * time.Second)
		}
	}
}