forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-slack-reminder.template.sh
executable file
·58 lines (48 loc) · 1.28 KB
/
add-slack-reminder.template.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# API: https://api.slack.com/methods/reminders.add
# Parameters
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Add Reminder
# @raycast.mode silent
# Optional parameters:
# @raycast.packageName Slack
# @raycast.icon ⏰
# @raycast.argument1 { "type": "text", "placeholder": "What" }
# @raycast.argument2 { "type": "text", "placeholder": "When" }
# Documentation:
# @raycast.description Create a Slack reminder
# @raycast.author Zeb Pykosz
# @raycast.authorURL https://github.com/zebapy
# Configuration
# To create a new API token, do the following:
# 1. Create a new Slack app at https://api.slack.com/authentication/basics
# 2. Add `reminders:write` to the user token scopes
# 3. Install the app to your workplace
# 4. Insert your OAuth access token below
API_TOKEN=""
if [[ -z "$API_TOKEN" ]]
then
echo "No API token provided"
exit 1
fi
RESPONSE=$(
curl \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $API_TOKEN" \
--request POST \
--data "{ 'text': '$1', 'time': '$2' }" \
--silent \
--output /dev/null \
--show-error \
--fail \
"https://slack.com/api/reminders.add"
)
if [[ "$RESPONSE" =~ "error" ]]
then
echo "Failed to add reminder in Slack"
exit 1
else
echo "Added reminder '$1 $2' in Slack!"
exit 0
fi