From 88efdbc8e093c5ffeee1c414bf6c682e4faab075 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 22 Nov 2022 14:59:13 +0800 Subject: Add mail hook --- tools/sns/mastodon.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 tools/sns/mastodon.sh (limited to 'tools') diff --git a/tools/sns/mastodon.sh b/tools/sns/mastodon.sh new file mode 100755 index 0000000..1118c20 --- /dev/null +++ b/tools/sns/mastodon.sh @@ -0,0 +1,12 @@ +#! /bin/bash + +MAIL="$(cat)" + +# Only execute the following script when mail receiver is mastodon@topo.tw +grep -qE "^To: .*mastodon@topo.tw[>]?$" <<<"$MAIL" || exit 0 + +date >>~/Downloads/mastodon.log +echo $$ >>~/Downloads/mastodon.log +awk -v RS= 'NR>1' <<<"$MAIL" >>~/Downloads/mastodon.log + +#awk -v RS= 'NR>1' <<<"$MAIL" | toot post >/tmp/mastodon.log -- cgit v1.2.3-70-g09d2