zahmis 5 лет назад
Родитель
Сommit
d512fdf25e

+ 37 - 15
packages/slack/src/services/register.ts

@@ -1,21 +1,43 @@
+import { WebClient, LogLevel } from '@slack/web-api';
 import { parse } from '../utils/slash-command-parser';
 
-export class RegisterService {
 
-  receiveBody(parseBody) {
-    const body = parse(parseBody);
-    const commandType = body.growiCommandArgs;
-    const commandArgs = body.growiCommandType;
+export const openModal = async(body) => {
 
-    if (commandType === 'register') {
-      this.openModal();
-      return;
-    }
-  }
+  const client = new WebClient('xoxb-1399660543842-1848670292404-huKeykaKhdyLyBqTiVlMxqY8', { logLevel: LogLevel.DEBUG });
 
-  openModal() {
-    console.log('open');
-  }
+  await client.views.open({
+    trigger_id: body.trigger_id,
+    view: {
+      type: 'modal',
+      title: {
+        type: 'plain_text',
+        text: 'My App',
+      },
+      close: {
+        type: 'plain_text',
+        text: 'Close',
+      },
+      blocks: [
+        {
+          type: 'section',
+          text: {
+            type: 'mrkdwn',
+            text: 'About',
+          },
+        },
+        {
+          type: 'context',
+          elements: [
+            {
+              type: 'mrkdwn',
+              text: 'Psssst',
+            },
+          ],
+        },
+      ],
+    },
+  });
 
-
-}
+  console.log('openModal');
+};

+ 13 - 3
packages/slackbot-proxy/src/services/RecieveService.ts

@@ -1,13 +1,23 @@
 import { Service } from '@tsed/di';
+import { JsonRequestBody } from '@tsed/schema';
+// import { parse } from '../../../slack/src/utils/slash-command-parser';
+import { openModal } from '../../../slack/src/services/register';
 
 @Service()
 export class ReceiveService {
 
   receive(body) {
+    if (body.text === 'register') {
+      console.log(body);
+      return this.register(body);
+    }
 
-    console.log('Receive Class', body);
-    console.log('wai');
-    return body;
+    return;
+  }
+
+  register(body) {
+
+    openModal(body);
   }
 
 }