Skip to content

Instantly share code, notes, and snippets.

@rra3
Created May 1, 2014 14:42
Show Gist options
  • Select an option

  • Save rra3/11453132 to your computer and use it in GitHub Desktop.

Select an option

Save rra3/11453132 to your computer and use it in GitHub Desktop.
func (ch *ChatHandler) HandleMessage(m *nsq.Message) error {
c := hipchat.Client{AuthToken: ""}
// http://stackoverflow.com/questions/14230145/what-is-the-best-way-to-convert-byte-array-to-string
n := bytes.Index(m.Body, []byte{0})
req := hipchat.MessageRequest{
RoomId: "546229",
From: "GoBot",
Message: string(m.Body[:n]),
Color: hipchat.ColorPurple,
MessageFormat: hipchat.FormatText,
Notify: true,
}
if err := c.PostMessage(req); err != nil {
log.Fatalf("failed to send message to hipchat: %s", err.Error())
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment