From d9466664eb5e2e9ab0497c40e4cd8c0f26b1cff8 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 2 May 2023 11:00:08 +0800 Subject: Update --- bin/mail/save_context.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 bin/mail/save_context.sh (limited to 'bin/mail/save_context.sh') diff --git a/bin/mail/save_context.sh b/bin/mail/save_context.sh new file mode 100755 index 0000000..5cc9400 --- /dev/null +++ b/bin/mail/save_context.sh @@ -0,0 +1,19 @@ +#! /bin/bash + +# Restore mail in variable +MAIL="$(cat)" + +# Only execute the following script when mail receiver is log@topo.tw +grep -qE "^X-Original-To: .*context@topo.tw[>]?$" <<<"$MAIL" || exit 0 +# A little hacky way to check if mail is sent from me +sed -nE '/^Received: /p;/^$/q' <<<"$(MAIL)" | wc -l | xargs -i test {} -lt 2 || exit 0 + +# Write a log +cat <<<"$MAIL" >>~/Downloads/context.log + +# Save content to log file of current week +/home/pham/helper/bin/task/context $(awk -v RS= 'NR>1' <<<"$MAIL") + +/home/pham/helper/bin/task/context | cut -f1-3 | /usr/bin/mail -r context@topo.tw -C "chat-version: 1.0" -s no-reply pham + +cd ~/log && git add context/* && git commit -m 'Append time by mail' -- cgit v1.2.3-70-g09d2