💾 Archived View for tilde.team › ~text › mention › sourcecode.txt captured on 2024-07-09 at 03:36:06.

View Raw

More Information

⬅️ Previous capture (2022-03-01)

-=-=-=-=-=-=-

#!/bin/bash

# URL of own capsule (grep string for mention)
capsule="gemini://gemini.capsule/~username/"
# Local file to append received reply URLs (chmod?)
replies="/home/username/public_gemini/replies.gmi"

function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }

if [[ -n $QUERY_STRING ]]; then
printf "20 text/gemini\r\n"
echo "# Thank you"

urlraw="$QUERY_STRING"
url=$(urldecode "$urlraw")
echo "Received the following reply URL:"
echo '```'
echo "$url"
echo '```'

domainpart=$(echo "$url"|awk -F/ '{print $3}')
echo "Trying to retrieve your reply content to check for the mention ..."
echo "Links back to my capsule that we found mentionend in your reply content:"
echo "$url" | openssl s_client -crlf -quiet -ign_eof -connect "$domainpart:1965" \
| grep "^=> $capsule"

if [[ $? -eq 0 ]]; then
echo
echo "Adding your URL to my list of received replies, thanks!"
echo "=> $url" >> "$replies"
else
echo "Sorry, could not find a link back to my capsule (or had other issues)."
fi

else
  printf "10 Please Enter Gemini URL of Your Reply\r\n"
fi