Exemple #1
0
// Send a message to hipchat, retrying every 10s for 120s if it cannot
func sendHipchat(token, from, room, message, color string) (err error) {
	defer Track("sendHipchat", Now(), debugOut)

	c := hipchat.NewClient(token)
	req := hipchat.MessageRequest{
		RoomId:        room,
		From:          from,
		Message:       message,
		Color:         color,
		MessageFormat: hipchat.FormatText,
		Notify:        true,
	}

	// we will make 12 attempts, 10s apart (120s total)
	// to deliver the message before simply giving up.
	// TODO: Deadletter handling
	for i := 0; i < 12; i++ {
		if err = c.PostMessage(req); err == nil {
			// Huzzah
			break
		} else {
			// Fail!
			time.Sleep(10 * time.Second)
		}
	}
	return
}
Exemple #2
0
func HipchatMessage(message string) {
	config := GetConfig()
	if config.HipchatAuthToken == "" || config.HipchatRoom == "" {
		return
	}

	client := hipchat.NewClient(config.HipchatAuthToken)

	err := client.PostMessage(hipchat.MessageRequest{
		RoomId:        config.HipchatRoom,
		From:          "SUP",
		Message:       message,
		Color:         hipchat.ColorRed,
		MessageFormat: hipchat.FormatText,
		Notify:        true,
	})

	check(err)
}