184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
# File 'lib/slackdo.rb', line 184
def add_task
file = File.read("#{ENV['HOME']}/.slackdo/config.json")
hash = JSON.parse(file)
webhook = hash['slack_webhook']
notifier = Slack::Notifier.new webhook
cli_category = $prompt.select('What is the category of this new task?', hash['categories'])
cli_message = $prompt.ask('Type your new task:')
want_note = $prompt.select('Do you want to add a note to this new task?', %w(Yes No))
cli_note = ''
while want_note == 'Yes'
note_text = $prompt.ask('Type your note:')
cli_note << "\n`- #{note_text}`"
want_note = $prompt.select('Do you want to add another note to the task?', %w(Yes No))
end
note = {
fallback: "This should've been a new note but looks like something went wrong...",
text: cli_note,
color: "gray",
mrkdwn_in: ["text"]
}
set_message(cli_message)
set_category(cli_category)
set_notes(cli_note)
notifier.post text: "• [#{cli_category}] #{cli_message}", attachments: [note]
puts 'Item was posted to Slack...'
end
|