diff --git a/messages.go b/messages.go index 09db54632..051ae67bb 100644 --- a/messages.go +++ b/messages.go @@ -46,9 +46,10 @@ type Msg struct { EventTimestamp string `json:"event_ts,omitempty"` // bot_message (https://api.slack.com/events/message/bot_message) - BotID string `json:"bot_id,omitempty"` - Username string `json:"username,omitempty"` - Icons *Icon `json:"icons,omitempty"` + BotID string `json:"bot_id,omitempty"` + Username string `json:"username,omitempty"` + Icons *Icon `json:"icons,omitempty"` + BotProfile *BotProfile `json:"bot_profile,omitempty"` // channel_join, group_join Inviter string `json:"inviter,omitempty"` @@ -112,6 +113,17 @@ type Icon struct { IconEmoji string `json:"icon_emoji,omitempty"` } +// BotProfile contains information about a bot +type BotProfile struct { + AppID string `json:"app_id,omitempty"` + Deleted bool `json:"deleted,omitempty"` + Icons *Icons `json:"icons,omitempty"` + ID string `json:"id,omitempty"` + Name string `json:"name,omitempty"` + TeamID string `json:"team_id,omitempty"` + Updated int64 `json:"updated,omitempty"` +} + // Edited indicates that a message has been edited. type Edited struct { User string `json:"user,omitempty"` diff --git a/messages_test.go b/messages_test.go index 3a05dc8f3..d47800e47 100644 --- a/messages_test.go +++ b/messages_test.go @@ -260,11 +260,29 @@ func TestComment(t *testing.T) { var botMessage = `{ "type": "message", "subtype": "bot_message", - "ts": "1358877455.000010", "text": "Pushing is the answer", + "suppress_notification": false, "bot_id": "BB12033", "username": "github", - "icons": {} + "icons": {}, + "team": "T01A9CUMPQA", + "bot_profile": { + "id": "BB12033", + "deleted": false, + "name": "github", + "updated": 1599574335, + "app_id": "A6DB2SWUW", + "icons": { + "image_36": "https://slack-files2.s3-us-west-2.amazonaws.com/avatars/2017-10-24/261138718469_ada58732a18da119678d_36.png", + "image_48": "https://slack-files2.s3-us-west-2.amazonaws.com/avatars/2017-10-24/261138718469_ada58732a18da119678d_48.png", + "image_72": "https://slack-files2.s3-us-west-2.amazonaws.com/avatars/2017-10-24/261138718469_ada58732a18da119678d_72.png" + }, + "team_id": "T01A9CUMPQA" + }, + "blocks": [], + "channel": "C01AZ844Z32", + "event_ts": "1358877455.000010", + "ts": "1358877455.000010" }` func TestBotMessage(t *testing.T) { @@ -280,6 +298,17 @@ func TestBotMessage(t *testing.T) { assert.NotNil(t, message.Icons) assert.Empty(t, message.Icons.IconURL) assert.Empty(t, message.Icons.IconEmoji) + assert.Equal(t, "github", message.BotProfile.Name) + assert.Equal(t, "BB12033", message.BotProfile.ID) + assert.Equal(t, false, message.BotProfile.Deleted) + assert.Equal(t, int64(1599574335), message.BotProfile.Updated) + assert.Equal(t, "A6DB2SWUW", message.BotProfile.AppID) + assert.Equal(t, "https://slack-files2.s3-us-west-2.amazonaws.com/avatars/2017-10-24/261138718469_ada58732a18da119678d_36.png", message.BotProfile.Icons.Image36) + assert.Equal(t, "https://slack-files2.s3-us-west-2.amazonaws.com/avatars/2017-10-24/261138718469_ada58732a18da119678d_48.png", message.BotProfile.Icons.Image48) + assert.Equal(t, "https://slack-files2.s3-us-west-2.amazonaws.com/avatars/2017-10-24/261138718469_ada58732a18da119678d_72.png", message.BotProfile.Icons.Image72) + assert.Equal(t, "T01A9CUMPQA", message.BotProfile.TeamID) + assert.Equal(t, "C01AZ844Z32", message.Channel) + assert.Equal(t, "1358877455.000010", message.EventTimestamp) } var meMessage = `{