nostril

A C cli tool for creating nostr events
git clone git://jb55.com/nostril
Log | Files | Refs | Submodules | README | LICENSE

nostril-post (551B)


      1 #!/usr/bin/env bash
      2 
      3 set -e
      4 
      5 TMP=$(mktemp)
      6 
      7 $EDITOR "$TMP"
      8 
      9 if [ ! -f "$TMP" ]; then
     10 	printf "could not create temporary file\n" >&2
     11 	exit 1
     12 fi
     13 
     14 content="$(cat $TMP)"
     15 
     16 re="^[[:space:]]*$" 
     17 if [[ "$content" =~ $re ]]; then
     18 	printf "note empty. aborting.\n" >&2
     19 	exit 2
     20 fi
     21 
     22 sec=""
     23 if command -v git; then
     24 	key=$(git config nostr.secretkey)
     25 	if [ $key != "" ]; then
     26 		sec="--sec $key"
     27 	fi
     28 fi
     29 
     30 note=$(nostril --envelope $sec "$@" --content "$content")
     31 
     32 printf "relaying:\n" >&2
     33 printf "$note\n"
     34 <<<"$note" nostril relay
     35 printf "done.\n" >&2
     36 
     37 rm -f "$TMP"