Explorar o código

add secondArg == null

zahmis %!s(int64=5) %!d(string=hai) anos
pai
achega
9ce88a0cd3
Modificáronse 1 ficheiros con 18 adicións e 8 borrados
  1. 18 8
      src/server/service/bolt.js

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

@@ -88,11 +88,28 @@ class BoltService {
 
 
       let resultPaths;
       let resultPaths;
 
 
+      if (firstArg === 'search' && secondArg == null) {
+        return this.client.chat.postEphemeral({
+          channel: command.channel_id,
+          user: command.user_id,
+          blocks: [
+            {
+              type: 'section',
+              text: {
+                type: 'mrkdwn',
+                text: '*キーワードを入力してください。*\n Hint\n `/growi search [keyword]`',
+              },
+            },
+          ],
+        });
+      }
+
       if (firstArg === 'search' && secondArg != null) {
       if (firstArg === 'search' && secondArg != null) {
         const { searchService } = this.crowi;
         const { searchService } = this.crowi;
         const option = { limit: 10 };
         const option = { limit: 10 };
         const searchResults = await searchService.searchKeyword(secondArg, null, {}, option);
         const searchResults = await searchService.searchKeyword(secondArg, null, {}, option);
 
 
+        // no search results
         if (searchResults.data.length === 0) {
         if (searchResults.data.length === 0) {
           return this.client.chat.postEphemeral({
           return this.client.chat.postEphemeral({
             channel: command.channel_id,
             channel: command.channel_id,
@@ -146,14 +163,7 @@ class BoltService {
               type: 'section',
               type: 'section',
               text: {
               text: {
                 type: 'mrkdwn',
                 type: 'mrkdwn',
-                text: '*検索に失敗しました。*',
-              },
-            },
-            {
-              type: 'section',
-              text: {
-                type: 'mrkdwn',
-                text: 'Hint\n /growi search [keyword]',
+                text: '*検索に失敗しました。*\n Hint\n `/growi search [keyword]`',
               },
               },
             },
             },
           ],
           ],