From 558f6ca52f461d8a16aa5c310b3a7cb8e6a2a45e Mon Sep 17 00:00:00 2001 From: Sebastian Mueller Date: Sun, 16 Apr 2023 12:52:11 +0200 Subject: [PATCH] fixes #18 I hope --- package.json | 2 +- src/mm-client.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 19904df..18fa4b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chatgpt-mattermost-bot", - "version": "1.3.2", + "version": "1.3.3", "private": true, "scripts": { "start": "node ./src/botservice.js" diff --git a/src/mm-client.js b/src/mm-client.js index abb3820..e180da2 100644 --- a/src/mm-client.js +++ b/src/mm-client.js @@ -15,15 +15,15 @@ client.setUrl(matterMostURLString) client.setToken(mattermostToken) const wsClient = new WebSocketClient(); -let matterMostURL = new URL(matterMostURLString); -const wsUrl = `${matterMostURL.protocol === 'https:' ? 'wss' : 'ws'}://${matterMostURL.host}/api/v4/websocket` +const wsUrl = new URL(client.getWebSocketUrl()); +wsUrl.protocol = wsUrl.protocol === 'https' ? 'wss' : 'ws' new Promise((resolve, reject) => { wsClient.addCloseListener(connectFailCount => reject()) wsClient.addErrorListener(event => { reject(event) }) }).then(() => process.exit(0)).catch(reason => { log.error(reason); process.exit(-1)}) -wsClient.initialize(wsUrl, mattermostToken) +wsClient.initialize(wsUrl.toString(), mattermostToken) module.exports = { mmClient: client,