Skip to content

Instantly share code, notes, and snippets.

@mattn

mattn/nostr.sh Secret

Last active April 1, 2023 08:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattn/0380def6f15a6ff0da2c66276bd774be to your computer and use it in GitHub Desktop.
Save mattn/0380def6f15a6ff0da2c66276bd774be to your computer and use it in GitHub Desktop.
#!/bin/bash
declare -A hashmap
PUBKEY=2c7cc62a697ea3a7826521f3fd34f0cb273693cbe5e9310f35449f43622a5cdc
curl -s "https://api.nostr.wine/search?kind=1&pubkey=$PUBKEY" | \
jq -r '.data[] | [.pubkey, .content] | @tsv' | while IFS=$'\t' read -r pubkey value; do
NAME=${hashmap[$pubkey]}
if [ -z "$NAME" ]; then
NAME=$(curl -s "https://api.nostr.wine/search?kind=0&pubkey=$pubkey" | jq -r '.data[0].content | fromjson.display_name')
if [ -z "$NAME" ]; then
hashmap[$pubkey]=unknown
else
hashmap[$pubkey]=$NAME
fi
fi
echo -e "$NAME: $value"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment