list nostr events, like and repost from bash

dependencies:
https://github.com/0xtrr/nostr-tool
https://github.com/fiatjaf/noscl

usage:

./profile.sh <npub>

script:

rm commands.tmp
privkarg="-p $(cat ~/.config/nostr/config.json | jq -r .privatekey)"
relaysarg=$(noscl relay | grep -oP "^wss://[^:]+" | while read r; do echo -n -r "$r "; done)

res=$(nostr-tool $relaysarg list-events -a $(key-convertr --to-hex $1) --timeout 5)

i=0
#IFS=$"\n"
echo "$res" | jq -c '.[] | del(.tags)' | head -n 3 |jq -r '"== note " + .id + " ==\n" + (.content | gsub("\n";" ")) + "\n\n''like:\n>nostr-tool '"$privkarg $relaysarg"'react -a " + .pubkey + " -e " + .id + " -r \"+\"\n\n''repost:\n>noscl publish nostr:$(key-convertr --kind note " + .id + ")\n"' | while read line
do
  match=$(echo "$line" | grep "^>")
  if [ "$match" != "" ]
  then
     let i++
     echo "$line" | perl -pe "s/^>//" >> commands.tmp
     line=$(echo "$line" | perl -pe "s/^>/[command $i]: /")
  fi

  echo $line
done

echo "type command number"
read c

$(cat commands.tmp | head -n $c | tail -n 1)
Edit

Pub: 01 Oct 2023 15:30 UTC

Views: 63