Skip to content

Commit

Permalink
hipchat notification with text message
Browse files Browse the repository at this point in the history
  • Loading branch information
keyki committed May 30, 2018
1 parent 96bb9a7 commit 6d38540
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions action/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@ type instancesMessage struct {
op *types.OpType
}

func (m *instancesMessage) HTMLMessage() string {
func (m *instancesMessage) TextMessage() string {
var buffer bytes.Buffer
buffer.WriteString(fmt.Sprintf("<b>Operation: %s</b><ul>", m.op.String()))
for _, inst := range m.Instances {
owner := inst.Owner
buffer.WriteString("/code\n")
for _, instance := range m.Instances {
owner := instance.Owner
if len(owner) == 0 {
owner = "???"
}
buffer.WriteString(fmt.Sprintf("<li>[%s] instance name: <b>%s</b> created: %s owner: <b>%s</b> region: <b>%s</b></li>", inst.CloudType, inst.Name, inst.Created, owner, inst.Region))
buffer.WriteString(fmt.Sprintf("[%s] instance name: %s created: %s owner: %s region: %s\n", instance.CloudType, instance.Name, instance.Created, owner, instance.Region))
}
buffer.WriteString("</ul>")
return buffer.String()
}
4 changes: 2 additions & 2 deletions hipchat/hipchat.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func (h *Hipchat) Send(message types.Message) error {
log.Infof("[HIPCHAT] %s", string(out))
} else {
_, err := client.Room.Notification(room, &hipchat.NotificationRequest{
Message: message.HTMLMessage(),
Message: message.TextMessage(),
Color: "green",
MessageFormat: "html",
MessageFormat: "text",
})
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion types/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Action interface {
}

type Message interface {
HTMLMessage() string
TextMessage() string
}

type Dispatcher interface {
Expand Down

0 comments on commit 6d38540

Please sign in to comment.