a fun bot for the hc slack
at v0.0.3 2.5 kB view raw
1import type { AnyMessageBlock } from "slack-edge"; 2import type { MessageResponse } from "../types"; 3 4export function getDescriptionBlocks(error?: string): MessageResponse { 5 const blocks: AnyMessageBlock[] = [ 6 { 7 type: "input", 8 block_id: "note_block", 9 element: { 10 type: "plain_text_input", 11 action_id: "note_input", 12 placeholder: { 13 type: "plain_text", 14 text: "Enter a note for your session", 15 }, 16 multiline: true, 17 }, 18 label: { 19 type: "plain_text", 20 text: "Note", 21 }, 22 }, 23 { 24 type: "actions", 25 elements: [ 26 { 27 type: "button", 28 text: { 29 type: "plain_text", 30 text: "🎬 Start Session", 31 emoji: true, 32 }, 33 value: "start", 34 action_id: "takes_start", 35 }, 36 { 37 type: "button", 38 text: { 39 type: "plain_text", 40 text: "⛔ Cancel", 41 emoji: true, 42 }, 43 value: "cancel", 44 action_id: "takes_status", 45 style: "danger", 46 }, 47 ], 48 }, 49 ]; 50 51 if (error) { 52 blocks.push( 53 { 54 type: "divider", 55 }, 56 { 57 type: "context", 58 elements: [ 59 { 60 type: "mrkdwn", 61 text: `⚠️ ${error}`, 62 }, 63 ], 64 }, 65 ); 66 } 67 68 return { 69 text: "Please enter a note for your session:", 70 response_type: "ephemeral", 71 blocks, 72 }; 73} 74 75export function getEditDescriptionBlocks( 76 description: string, 77 error?: string, 78): MessageResponse { 79 const blocks: AnyMessageBlock[] = [ 80 { 81 type: "input", 82 block_id: "note_block", 83 element: { 84 type: "plain_text_input", 85 action_id: "note_input", 86 placeholder: { 87 type: "plain_text", 88 text: "Enter a note for your session", 89 }, 90 multiline: true, 91 initial_value: description, 92 }, 93 label: { 94 type: "plain_text", 95 text: "Note", 96 }, 97 }, 98 { 99 type: "actions", 100 elements: [ 101 { 102 type: "button", 103 text: { 104 type: "plain_text", 105 text: "✍️ Update Note", 106 emoji: true, 107 }, 108 value: "start", 109 action_id: "takes_edit", 110 }, 111 { 112 type: "button", 113 text: { 114 type: "plain_text", 115 text: "⛔ Cancel", 116 emoji: true, 117 }, 118 value: "cancel", 119 action_id: "takes_status", 120 style: "danger", 121 }, 122 ], 123 }, 124 ]; 125 126 if (error) { 127 blocks.push( 128 { 129 type: "divider", 130 }, 131 { 132 type: "context", 133 elements: [ 134 { 135 type: "mrkdwn", 136 text: `⚠️ ${error}`, 137 }, 138 ], 139 }, 140 ); 141 } 142 143 return { 144 text: "Please enter a note for your session:", 145 response_type: "ephemeral", 146 blocks, 147 }; 148}