2022-04-23 10:52:41 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
TMP=$(mktemp)
|
|
|
|
|
|
|
|
$EDITOR "$TMP"
|
|
|
|
|
|
|
|
if [ ! -f "$TMP" ]; then
|
|
|
|
printf "could not create temporary file\n" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
content="$(cat $TMP)"
|
|
|
|
|
|
|
|
re="^[[:space:]]*$"
|
|
|
|
if [[ "$content" =~ $re ]]; then
|
|
|
|
printf "note empty. aborting.\n" >&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2022-12-01 09:42:27 -05:00
|
|
|
sec=""
|
|
|
|
if command -v git; then
|
|
|
|
key=$(git config nostr.secretkey)
|
|
|
|
if [ $key != "" ]; then
|
|
|
|
sec="--sec $key"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
note=$(nostril --envelope $sec "$@" --content "$content")
|
2022-04-23 10:52:41 -04:00
|
|
|
|
|
|
|
printf "relaying:\n" >&2
|
|
|
|
printf "$note\n"
|
2022-12-01 09:42:27 -05:00
|
|
|
<<<"$note" nostril relay
|
2022-04-23 10:52:41 -04:00
|
|
|
printf "done.\n" >&2
|
|
|
|
|
|
|
|
rm -f "$TMP"
|