Skip to content

Commit

Permalink
Fix slack-connector
Browse files Browse the repository at this point in the history
  • Loading branch information
clvs7-gh committed Jul 11, 2024
1 parent 6167239 commit ce485b4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rec0-bot",
"version": "2.3.1",
"version": "2.4.1",
"description": "A bot for revolution of comm :)",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/environment/environment.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as path from 'path';
import { Environment } from '../interface/environment.interface';

export const environmentDev: Environment = {
version: '2.3.1',
version: '2.4.1',
isProduction: false,
slack: {
token: {
Expand Down
2 changes: 1 addition & 1 deletion src/environment/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as path from 'path';
import { Environment } from '../interface/environment.interface';

export const environmentProd: Environment = {
version: '2.3.1',
version: '2.4.1',
isProduction: true,
slack: {
token: {
Expand Down
19 changes: 12 additions & 7 deletions src/service/connector/slack-connector.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Connector } from '../../interface/connector.interface';
export class SlackConnectorService extends EventEmitter implements Connector {
private sockClient: SocketModeClient;
private webClient: WebClient;
private _ready: Promise<any> | undefined;
private _ready: Promise<void> | undefined;

private botUserId = '';

Expand All @@ -24,13 +24,13 @@ export class SlackConnectorService extends EventEmitter implements Connector {

async init() {
this._ready = new Promise(async (resolve, reject) => {
const result = await this.sockClient.start();
if (result.ok) {
try {
await this.sockClient.start();
this.subscribeEvents();
this.botUserId = await this.getBotUserId(false);
resolve(result);
} else {
reject(result);
resolve();
} catch (e) {
reject(e);
}
});
await this._ready;
Expand Down Expand Up @@ -116,7 +116,12 @@ export class SlackConnectorService extends EventEmitter implements Connector {

private subscribeEvents() {
this.SUBSCRIBE_EVENTS.forEach((ev) => this.sockClient.on(ev, async ({event, body, ack}) => {
await ack();
if (ack) {
await ack();
}
if (!event) {
return;
}
const value = event;
if (ev === 'message') {
// Add some properties
Expand Down

0 comments on commit ce485b4

Please sign in to comment.