From 2c5c81236301461bf5bcbdb39a7eeba919fa466a Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Fri, 4 Jun 2021 15:19:02 +0900 Subject: [PATCH] Fix #956 Add bot_id / bot_profile to GenericMessageEvent --- src/types/events/message-events.spec.ts | 30 ++++++++++++++++++++++++- src/types/events/message-events.ts | 14 ++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/types/events/message-events.spec.ts b/src/types/events/message-events.spec.ts index b1468867c..2b7604250 100644 --- a/src/types/events/message-events.spec.ts +++ b/src/types/events/message-events.spec.ts @@ -1,6 +1,6 @@ // tslint:disable:no-implicit-dependencies import { assert } from 'chai'; -import { BotMessageEvent, MessageEvent } from './message-events'; +import { BotMessageEvent, GenericMessageEvent, MessageEvent } from './message-events'; describe('message event types', () => { it('should be compatible with bot_message payload', () => { @@ -155,4 +155,32 @@ describe('message event types', () => { }; assert.isNotEmpty(payload); }); + it('should be compatible with message with bot info', () => { + const payload: GenericMessageEvent = { + type: 'message', + subtype: undefined, + text: 'Hi there! Thanks for sharing the info!', + user: 'UB111', + ts: '1610261539.000900', + team: 'T111', + bot_id: 'B999', + bot_profile: { + id: 'B999', + deleted: false, + name: 'other-app', + updated: 1607307935, + app_id: 'A222', + icons: { + image_36: 'https://a.slack-edge.com/80588/img/plugins/app/bot_36.png', + image_48: 'https://a.slack-edge.com/80588/img/plugins/app/bot_48.png', + image_72: 'https://a.slack-edge.com/80588/img/plugins/app/service_72.png', + }, + team_id: 'T111', + }, + channel: 'C111', + event_ts: '1610261539.000900', + channel_type: 'channel', + }; + assert.isNotEmpty(payload); + }); }); diff --git a/src/types/events/message-events.ts b/src/types/events/message-events.ts index 9832a1b2b..c40cd283b 100644 --- a/src/types/events/message-events.ts +++ b/src/types/events/message-events.ts @@ -26,6 +26,8 @@ export interface GenericMessageEvent { team?: string; channel: string; user: string; + bot_id?: string; + bot_profile?: BotProfile; text?: string; ts: string; thread_ts?: string; @@ -281,6 +283,18 @@ export interface ThreadBroadcastMessageEvent { export type channelTypes = 'channel' | 'group' | 'im' | 'mpim' | 'app_home'; +interface BotProfile { + id: string; + name: string; + app_id: string; + team_id: string; + icons: { + [size: string]: string; + }; + updated: number; + deleted: boolean; +} + interface File { id: string; created: number;