-
Notifications
You must be signed in to change notification settings - Fork 0
/
ntfy.sh
executable file
·60 lines (53 loc) · 1.38 KB
/
ntfy.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
59
60
#!/bin/bash --
TITLE=""
PRIORITY=""
TAGS=""
TOPIC="bft"
TEXT=""
HELP='
RUN: ntfy.sh [-t "My Title"] [-p "high"] [-a "tag1,tag2"] [--topic "bft"] Here goes my message
Params:
-t, --title, [optional] a title for the alert
-p, --priority, [optional] The priorities are: min, low, default, high or urgent
-a, --tags, [optional] one or more tags separate by comma with no spaces*
--topic [optional] the topic/channel on which the message will be sent to
List of emojis that can be used as tags: https://brunofontes.net:9795/docs/emojis/
'
[[ -z $1 ]] && echo -e "$HELP" && exit 1
while [[ $# -gt 0 ]]
do
case $1 in
-t|--title)
#TITLE="-H \"Title: $2\""
TITLE="$2"
shift && shift
;;
-p|--priority)
PRIORITY="$2"
shift && shift
;;
-a|--tags)
TAGS="$2"
shift && shift
;;
--topic)
TOPIC="$2"
shift && shift
;;
-h|--help)
echo -e "$HELP"
exit 0
;;
*)
[[ -z $TEXT ]] && TEXT="$1" || TEXT="$TEXT $1"
shift
;;
esac
done
TOKEN=$(pass ntfy)
/usr/bin/curl -H "Authorization: Bearer $TOKEN" \
-H "Title: $TITLE" \
-H "Priority: $PRIORITY" \
-H "Tags: $TAGS" \
-d "$TEXT" \
https://brunofontes.net:9795/$TOPIC