RegisterService.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { Service } from '@tsed/di';
  2. import { WebClient, LogLevel } from '@slack/web-api';
  3. import { generateInputSectionBlock } from '@growi/slack';
  4. import { GrowiCommandsMappings } from '../interfaces/growi-commands-mappings';
  5. @Service()
  6. export class RegisterService implements GrowiCommandsMappings {
  7. async execSlashCommand(body:{[key:string]:string}):Promise<void> {
  8. // tmp use process.env
  9. const client = new WebClient(process.env.SLACK_BOT_USER_OAUTH_TOKEN, { logLevel: LogLevel.DEBUG });
  10. await client.views.open({
  11. trigger_id: body.trigger_id,
  12. view: {
  13. type: 'modal',
  14. title: {
  15. type: 'plain_text',
  16. text: 'Register Credentials',
  17. },
  18. submit: {
  19. type: 'plain_text',
  20. text: 'Submit',
  21. },
  22. close: {
  23. type: 'plain_text',
  24. text: 'Close',
  25. },
  26. blocks: [
  27. generateInputSectionBlock('growiDomain', 'GROWI domain', 'contents_input', false, 'https://example.com'),
  28. generateInputSectionBlock('growiAccessToken', 'GROWI ACCESS_TOKEN', 'contents_input', false, 'jBMZvpk.....'),
  29. generateInputSectionBlock('proxyToken', 'PROXY ACCESS_TOKEM', 'contents_input', false, 'jBMZvpk.....'),
  30. ],
  31. },
  32. });
  33. }
  34. }