diff --git a/lib/bot.js b/lib/bot.js index db91530..70c1f6a 100644 --- a/lib/bot.js +++ b/lib/bot.js @@ -1,9 +1,5 @@ -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 WebClient = require('@slack/client').WebClient; var winston = require('winston'); var Promise = require('bluebird'); var Natural = require('natural'); @@ -53,12 +49,12 @@ 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, {dataStore : self.dataStore, logLevel : 'debug'}); + this.rtm = new RtmClient(this.token, {useRtmConnect: true, dataStore : false, logLevel : 'debug'}); } else { - this.rtm = new RtmClient(this.token, {dataStore : self.dataStore}); + this.rtm = new RtmClient(this.token, {useRtmConnect: true, dataStore : false}); } + this.web = new WebClient(this.token); if (this.logLevel === 'TEST'){ winston.log = function () {}; } @@ -317,8 +313,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" }