From c80d4944b9e20612f27b1286f1e93cbed63c3601 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Wed, 28 Oct 2020 17:09:13 +0200
Subject: [PATCH] Handle forms in spammer.

With the new spam page in my site, I'm using an HTML form. Handle both
the simpler POSTs and the HTML forms.
---
 Documents/bin/spammer | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/Documents/bin/spammer b/Documents/bin/spammer
index f05904b..aa55fdf 100755
--- a/Documents/bin/spammer
+++ b/Documents/bin/spammer
@@ -1,13 +1,22 @@
 #!/bin/sh
 set -eu
 
+URL='https://patchbay.pub/pubsub/1446c969-9a54-4b5b-83e0-bf88f22f289d'
+
 while true
 do
-    # Backoff in case of an error.
-    if ! notify-send \
+    message="$(curl --silent "$URL")"
+    exitstatus="$?"
+    if echo "$message" | grep --silent '^message='
+    then
+        message="$(echo "$message" | sed 's/message=//; s/+/ /g')"
+    fi
+    notify-send \
         --urgency low \
         --hint "string:desktop-entry:spammer" \
-        "$(curl --silent https://patchbay.pub/pubsub/1446c969-9a54-4b5b-83e0-bf88f22f289d)"
+        "$message"
+    # Backoff in case of an error.
+    if [ "$exitstatus" -gt '0' ]
     then
         sleep 1
     fi
-- 
GitLab