From f9ec1d1aa37f18e46c6d169ad3255e421cb5c00b Mon Sep 17 00:00:00 2001 From: William Casarin Date: Thu, 1 Dec 2022 06:42:27 -0800 Subject: [PATCH] cleanup scripts --- scripts/nostr-contact | 2 -- scripts/nostr-query | 2 -- scripts/nostr-relay-note | 3 --- scripts/{nostr-post => nostril-post} | 12 ++++++++++-- scripts/nostril-relay | 17 +++++++++++++++++ 5 files changed, 27 insertions(+), 9 deletions(-) delete mode 100755 scripts/nostr-contact delete mode 100755 scripts/nostr-query delete mode 100755 scripts/nostr-relay-note rename scripts/{nostr-post => nostril-post} (63%) create mode 100755 scripts/nostril-relay diff --git a/scripts/nostr-contact b/scripts/nostr-contact deleted file mode 100755 index 12f412f..0000000 --- a/scripts/nostr-contact +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -echo '["REQ","",{"kinds":[0],"authors":["'$1'"]}]' diff --git a/scripts/nostr-query b/scripts/nostr-query deleted file mode 100755 index de7396f..0000000 --- a/scripts/nostr-query +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -websocat "$@" wss://relay.damus.io diff --git a/scripts/nostr-relay-note b/scripts/nostr-relay-note deleted file mode 100755 index 5921d23..0000000 --- a/scripts/nostr-relay-note +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -jq -c '["EVENT",.]' | websocat wss://relay.damus.io diff --git a/scripts/nostr-post b/scripts/nostril-post similarity index 63% rename from scripts/nostr-post rename to scripts/nostril-post index 014a433..ec2e373 100755 --- a/scripts/nostr-post +++ b/scripts/nostril-post @@ -19,11 +19,19 @@ if [[ "$content" =~ $re ]]; then exit 2 fi -note=$(nostril "$@" --content "$content") +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") printf "relaying:\n" >&2 printf "$note\n" -<<<"$note" nostr-relay-note +<<<"$note" nostril relay printf "done.\n" >&2 rm -f "$TMP" diff --git a/scripts/nostril-relay b/scripts/nostril-relay new file mode 100755 index 0000000..f7285f5 --- /dev/null +++ b/scripts/nostril-relay @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +relays=${NOSTR_RELAYS:-$(git config nostr.relays)} +relayer=${NOSTR_RELAYER:-nostcat} +to_stdout=0 + +if ! command -v $relayer; then + printf "nostr relayer '%s' not found. Please install or set NOSTR_RELAYER to your preferred relayer.\n" "$relayer" + exit 1 +fi + +if [ "$relays" == "" ]; then + printf 'no relays set. set\n\n export NOSTR_RELAYS="wss://relay1.com wss://relay2.com ..." or\n\n git config --global --add nostr.relays "wss://relay1.com wss://relay2.com"\n' >&2 + exit 1 +fi + +$relayer $relays