93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/slackdo.rb', line 93
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 = HighLine.new
category = cli.ask 'What is the category of this new task? eg. DEV or GENERAL'
cli_message = cli.ask 'Type your new task:'
want_note = cli.ask 'Do you want to add a note to this new task? y/n'
cli_note = ''
while want_note == 'y'
note_text = cli.ask 'Type your note:'
cli_note << "\n`- #{note_text}`"
want_note = cli.ask 'Do you want to add another note to the task? y/n'
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("[#{category}] #{cli_message}")
set_notes(cli_note)
notifier.post text: "• [#{category}] #{cli_message}", attachments: [note]
puts 'Item was posted to Slack...'
end
|