itizawa %!s(int64=5) %!d(string=hai) anos
pai
achega
90374507fa
Modificáronse 1 ficheiros con 26 adicións e 13 borrados
  1. 26 13
      src/server/service/bolt.js

+ 26 - 13
src/server/service/bolt.js

@@ -55,25 +55,38 @@ class BoltService {
   constructor(crowi) {
   constructor(crowi) {
     this.crowi = crowi;
     this.crowi = crowi;
     this.receiver = new BoltReciever();
     this.receiver = new BoltReciever();
+    this.client = null;
 
 
-    const signingSecret = crowi.configManager.getConfig('crowi', 'slackbot:signingSecret');
-    const token = crowi.configManager.getConfig('crowi', 'slackbot:token');
+    this.isBoltSetup = false;
 
 
-    const client = new WebClient(token, { logLevel: LogLevel.DEBUG });
-    this.client = client;
+    this.init();
+  }
 
 
-    if (token != null || signingSecret != null) {
-      logger.debug('SlackBot: setup is done');
-      this.bolt = new App({
-        token,
-        signingSecret,
-        receiver: this.receiver,
-      });
-      this.init();
+  init() {
+    this.isBoltSetup = false;
+
+    const token = this.crowi.configManager.getConfig('crowi', 'slackbot:token');
+    const signingSecret = this.crowi.configManager.getConfig('crowi', 'slackbot:signingSecret');
+
+    this.client = new WebClient(token, { logLevel: LogLevel.DEBUG });
+
+    if (token == null || signingSecret == null) {
+      this.bolt = null;
+      return;
     }
     }
+
+    this.bolt = new App({
+      token,
+      signingSecret,
+      receiver: this.receiver,
+    });
+    this.setupRoute();
+
+    logger.debug('SlackBot: setup is done');
+    this.isBoltSetup = true;
   }
   }
 
 
-  init() {
+  setupRoute() {
     this.bolt.command('/growi', async({
     this.bolt.command('/growi', async({
       command, client, body, ack,
       command, client, body, ack,
     }) => {
     }) => {