Skip to content

Commit

Permalink
Fix #956 Add bot_id / bot_profile to GenericMessageEvent (#957)
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch authored Jun 4, 2021
1 parent 4857d40 commit d142ab1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/types/events/message-events.spec.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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);
});
});
14 changes: 14 additions & 0 deletions src/types/events/message-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d142ab1

Please sign in to comment.