@@ -4,6 +4,9 @@ const moment = require('moment')
44if ( ! global . WebSocket ) {
55 global . WebSocket = require ( 'ws' ) ;
66}
7+ client = require ( '@mattermost/client' ) ;
8+ const Client4 = client . Client4 ;
9+ const WebSocketClient = client . WebSocketClient ;
710
811if ( ! String . prototype . format ) {
912 String . prototype . format = function ( ) {
@@ -302,22 +305,19 @@ class PaperBot {
302305 }
303306
304307 initChatConnection ( config ) {
305- const Client4 = require ( '../node_modules/mattermost-redux/client/client4.js' ) . default ;
306308 this . client = new Client4 ;
307- this . wsClient = require ( '../node_modules/mattermost-redux/client/websocket_client.js' ) . default ;
309+ this . wsClient = new WebSocketClient ( ) ;
308310 const {
309311 Post,
310312 PostList,
311313 PostSearchResults,
312314 OpenGraphMetadata
313- } = require ( "../node_modules/ mattermost-redux /types/posts" ) ;
315+ } = require ( "@ mattermost/types/posts" ) ;
314316
315317 this . client . setUrl ( config . apiUrl ) ;
316318 this . client . setToken ( config . token ) ;
317319 this . client . setIncludeCookies ( false ) ;
318- this . wsClient . initialize ( config . token , {
319- connectionUrl : config . websocketUrl
320- } ) ;
320+ this . wsClient . initialize ( config . websocketUrl , config . token ) ;
321321
322322 this . stats . api . requests_sent += 1 ;
323323 this . client . getMe ( ) . then ( ( profile ) => {
@@ -550,7 +550,7 @@ class PaperBot {
550550 this . stats . paper_requests_handled += 1 ;
551551
552552 const paper_request_regex = / (?: ( C | E | L E ? ) W G | F S | S D | N | P | D | E D I T ) ? \d + ( R \d + ) ? / gi;
553- const papers_requested = [ ...post . message . matchAll ( paper_request_regex ) ] . map ( m => m [ 1 ] ) ;
553+ const papers_requested = [ ...post . message . matchAll ( paper_request_regex ) ] . map ( m => m [ 0 ] ) ;
554554 this . handlePaperRequest ( post , papers_requested , true ) ;
555555 }
556556
0 commit comments