aboutsummaryrefslogtreecommitdiff
path: root/events.sh
diff options
context:
space:
mode:
Diffstat (limited to 'events.sh')
-rw-r--r--events.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/events.sh b/events.sh
new file mode 100644
index 0000000..6704def
--- /dev/null
+++ b/events.sh
@@ -0,0 +1,22 @@
+atrocity_on_dispatch() {
+ local event
+ event="$(printf '%s' "$1" | jq -r .t)"
+ atrocity_on_event "$event" "$(printf '%s' "$1" | jq .d)"
+}
+
+atrocity_on_event() {
+ atrocity_on_default_event "$1" "$2"
+}
+atrocity_on_default_event() {
+ local handler
+ handler="atrocity_on_$1"
+ if declare -F "$handler" >/dev/null; then
+ "$handler" "$2"
+ else
+ atrocity_on_unknown "$1" "$2"
+ fi
+}
+
+atrocity_on_unknown() {
+ noop
+}