示例#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)
}
示例#2
0
文件: main.go 项目: oblank/go-notify
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()
}