zahmis 5 лет назад
Родитель
Сommit
00b48a4857
1 измененных файлов с 19 добавлено и 8 удалено
  1. 19 8
      src/server/service/bolt.js

+ 19 - 8
src/server/service/bolt.js

@@ -86,13 +86,20 @@ class BoltService {
       await ack();
       const inputSlack = command.text.split(' ');
       const firstArg = inputSlack[0];
-      const secondArg = inputSlack[1];
 
-      if (firstArg === 'search') {
-        return this.searchResults(command, secondArg);
-      }
+      switch (firstArg) {
+        case 'search':
+          this.searchResults(command, inputSlack);
+          break;
+
+        case 'create':
+          console.log('create');
+          break;
 
-      return this.notCommand(command);
+        default:
+          this.notCommand(command);
+          break;
+      }
     });
 
   }
@@ -109,9 +116,12 @@ class BoltService {
 
   }
 
-  async searchResults(command, secondArg) {
+  async searchResults(command, inputSlack) {
+    console.log(inputSlack);
+    const growiCommand = inputSlack[0];
+    const keyword = inputSlack[1];
 
-    if (secondArg == null) {
+    if (growiCommand == null) {
       return this.client.chat.postEphemeral({
         channel: command.channel_id,
         user: command.user_id,
@@ -123,7 +133,8 @@ class BoltService {
 
     const { searchService } = this.crowi;
     const option = { limit: 10 };
-    const results = await searchService.searchKeyword(secondArg, null, {}, option);
+    const results = await searchService.searchKeyword(keyword, null, {}, option);
+
     // no search results
     if (results.data.length === 0) {
       return this.client.chat.postEphemeral({