From 238c8cf12599a5ce76e35801b88327bf8925e106 Mon Sep 17 00:00:00 2001 From: Michael Meyers Date: Thu, 16 Sep 2021 15:24:15 -0400 Subject: [PATCH 1/4] Update bot.js --- lib/bot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bot.js b/lib/bot.js index db91530..007e39a 100644 --- a/lib/bot.js +++ b/lib/bot.js @@ -138,7 +138,7 @@ function OpkitBot(name, cmds, persister, params) { this.start = function(){ return this.persister.start() .then(function() { - self.rtm.start(); + self.rtm.connect(); return Promise.resolve(true); }); }; From 39bfa653be012886a59e97046b089085d0188c5d Mon Sep 17 00:00:00 2001 From: Michael Meyers Date: Fri, 17 Sep 2021 10:04:49 -0400 Subject: [PATCH 2/4] use `useRtmConnect: true` and call start instead of connect --- lib/bot.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/bot.js b/lib/bot.js index 007e39a..ed90a87 100644 --- a/lib/bot.js +++ b/lib/bot.js @@ -55,9 +55,9 @@ function OpkitBot(name, cmds, persister, params) { this.token = params.token; this.dataStore = new MemoryDataStore(); if (this.logLevel === 'DEBUG'){ - this.rtm = new RtmClient(this.token, {dataStore : self.dataStore, logLevel : 'debug'}); + this.rtm = new RtmClient(this.token, {useRtmConnect: true, dataStore : self.dataStore, logLevel : 'debug'}); } else { - this.rtm = new RtmClient(this.token, {dataStore : self.dataStore}); + this.rtm = new RtmClient(this.token, {useRtmConnect: true, dataStore : self.dataStore}); } if (this.logLevel === 'TEST'){ winston.log = function () {}; @@ -138,7 +138,7 @@ function OpkitBot(name, cmds, persister, params) { this.start = function(){ return this.persister.start() .then(function() { - self.rtm.connect(); + self.rtm.start(); return Promise.resolve(true); }); }; From b2d8dc579f971b637fe5baf1c8aee0dc33cd2e87 Mon Sep 17 00:00:00 2001 From: Michael Meyers Date: Fri, 17 Sep 2021 16:54:34 -0400 Subject: [PATCH 3/4] upgrade slack client --- lib/bot.js | 16 +++++----------- package.json | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/bot.js b/lib/bot.js index ed90a87..b0e2ee5 100644 --- a/lib/bot.js +++ b/lib/bot.js @@ -1,9 +1,4 @@ -var CLIENT_EVENTS = require('slack-client').CLIENT_EVENTS; -var RTM_EVENTS = require('slack-client').RTM_EVENTS; -var RTM_CLIENT_EVENTS = require('slack-client').CLIENT_EVENTS.RTM; -var RtmClient = require('slack-client').RtmClient; -var MemoryDataStore = require('slack-client').MemoryDataStore; -var Auth = require('./auth'); +var RtmClient = require('@slack/client').RTMClient; var winston = require('winston'); var Promise = require('bluebird'); var Natural = require('natural'); @@ -53,11 +48,10 @@ function OpkitBot(name, cmds, persister, params) { this.oneoffHandlers = []; this.logLevel = params.logLevel; this.token = params.token; - this.dataStore = new MemoryDataStore(); if (this.logLevel === 'DEBUG'){ - this.rtm = new RtmClient(this.token, {useRtmConnect: true, dataStore : self.dataStore, logLevel : 'debug'}); + this.rtm = new RtmClient(this.token, {useRtmConnect: true, dataStore : false, logLevel : 'debug'}); } else { - this.rtm = new RtmClient(this.token, {useRtmConnect: true, dataStore : self.dataStore}); + this.rtm = new RtmClient(this.token, {useRtmConnect: true, dataStore : false}); } if (this.logLevel === 'TEST'){ winston.log = function () {}; @@ -317,8 +311,8 @@ function OpkitBot(name, cmds, persister, params) { }); }; - this.rtm.on(CLIENT_EVENTS.RTM.AUTHENTICATED); - this.rtm.on(RTM_EVENTS.MESSAGE, this.onEventsMessage); + // this.rtm.on('authenticated'); + this.rtm.on('message', this.onEventsMessage); } diff --git a/package.json b/package.json index f13f993..8b2ae0c 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "sinon-as-promised": "^4.0.0" }, "dependencies": { + "@slack/client": "^5.0.2", "aws-promised": "^2.13.0", "aws-sdk": "^2.3.10", "bluebird": "^3.4.0", @@ -49,7 +50,6 @@ "natural": "^0.5.0", "pg-promise": "^4.8.1", "redis": "^2.6.2", - "slack-client": "^2.0.6", "url-parse": "^1.1.1", "winston": "^2.2.0" } From f832e4ad61e7e751fe271f9ee5c4f95386bb9c9d Mon Sep 17 00:00:00 2001 From: Michael Meyers Date: Fri, 17 Sep 2021 17:06:33 -0400 Subject: [PATCH 4/4] create web client --- lib/bot.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/bot.js b/lib/bot.js index b0e2ee5..70c1f6a 100644 --- a/lib/bot.js +++ b/lib/bot.js @@ -1,4 +1,5 @@ var RtmClient = require('@slack/client').RTMClient; +var WebClient = require('@slack/client').WebClient; var winston = require('winston'); var Promise = require('bluebird'); var Natural = require('natural'); @@ -53,6 +54,7 @@ function OpkitBot(name, cmds, persister, params) { } else { this.rtm = new RtmClient(this.token, {useRtmConnect: true, dataStore : false}); } + this.web = new WebClient(this.token); if (this.logLevel === 'TEST'){ winston.log = function () {}; }