| Conditions | 9 |
| Total Lines | 43 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import {chat_v1 as chatV1} from 'googleapis/build/src/apis/chat/v1'; |
||
| 7 | process(): chatV1.Schema$Message { |
||
| 8 | const argumentText = this.event.message?.argumentText?.trim() ?? ''; |
||
| 9 | const helpResponse = { |
||
| 10 | thread: this.event.message!.thread, |
||
| 11 | actionResponse: { |
||
| 12 | type: 'NEW_MESSAGE', |
||
| 13 | }, |
||
| 14 | text: 'Hi there! I can help you create polls to enhance collaboration and efficiency ' + |
||
| 15 | 'in decision-making using Google Chat™.\n' + |
||
| 16 | '\n' + |
||
| 17 | 'Below is an example commands:\n' + |
||
| 18 | '`/poll` - You will need to fill out the topic and answers in the form that will be displayed.\n' + |
||
| 19 | '`/poll "Which is the best country to visit" "Indonesia"` - to create a poll with ' + |
||
| 20 | '"Which is the best country to visit" as the topic and "Indonesia" as the answer\n' + |
||
| 21 | '\n' + |
||
| 22 | 'We hope you find our service useful and please don\'t hesitate to contact us ' + |
||
| 23 | 'if you have any questions or concerns.', |
||
| 24 | }; |
||
| 25 | switch (argumentText) { |
||
| 26 | case 'help': |
||
| 27 | return helpResponse; |
||
| 28 | default: |
||
| 29 | const choices = splitMessage(argumentText); |
||
| 30 | if (choices.length > 2) { |
||
| 31 | const pollCard = new PollCard({ |
||
| 32 | choiceCreator: undefined, |
||
| 33 | topic: choices.shift() ?? '', |
||
| 34 | author: this.event.user, |
||
| 35 | choices: choices, |
||
| 36 | votes: {}, |
||
| 37 | anon: false, |
||
| 38 | optionable: true, |
||
| 39 | }); |
||
| 40 | const message = pollCard.createMessage(); |
||
| 41 | return { |
||
| 42 | thread: this.event.message!.thread, |
||
| 43 | actionResponse: { |
||
| 44 | type: 'NEW_MESSAGE', |
||
| 45 | }, |
||
| 46 | ...message, |
||
| 47 | }; |
||
| 48 | } |
||
| 49 | return helpResponse; |
||
| 50 | } |
||
| 53 |