nostril

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

commit f9ec1d1aa37f18e46c6d169ad3255e421cb5c00b
parent 0ee25a0afa623489cb5a17d066f717f30b8723f8
Author: William Casarin <jb55@jb55.com>
Date:   Thu,  1 Dec 2022 06:42:27 -0800

cleanup scripts

Diffstat:
Dscripts/nostr-contact | 2--
Dscripts/nostr-post | 29-----------------------------
Dscripts/nostr-query | 2--
Dscripts/nostr-relay-note | 3---
Ascripts/nostril-post | 37+++++++++++++++++++++++++++++++++++++
Ascripts/nostril-relay | 17+++++++++++++++++
6 files changed, 54 insertions(+), 36 deletions(-)

diff --git a/scripts/nostr-contact b/scripts/nostr-contact @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -echo '["REQ","",{"kinds":[0],"authors":["'$1'"]}]' diff --git a/scripts/nostr-post b/scripts/nostr-post @@ -1,29 +0,0 @@ -#!/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 - -note=$(nostril "$@" --content "$content") - -printf "relaying:\n" >&2 -printf "$note\n" -<<<"$note" nostr-relay-note -printf "done.\n" >&2 - -rm -f "$TMP" diff --git a/scripts/nostr-query b/scripts/nostr-query @@ -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 @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -jq -c '["EVENT",.]' | websocat wss://relay.damus.io diff --git a/scripts/nostril-post b/scripts/nostril-post @@ -0,0 +1,37 @@ +#!/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 + +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" nostril relay +printf "done.\n" >&2 + +rm -f "$TMP" diff --git a/scripts/nostril-relay 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