list nostr events, like and repost from bash

dependencies:

usage:

./noscmd.sh <npub> <limit>

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)

c=0
echo "$res" | jq -c '.[] | del(.tags)' | head -n $2 |jq -r '.id + "\n" + (.content | gsub("\n";" ")) + "\n''nostr-tool '"$privkarg $relaysarg"'react -a " + .pubkey + " -e " + .id + " -r \"+\"\n''noscl publish nostr:$(key-convertr --kind note " + .id + ")"' > res.tmp

let j=1
for c in $(seq 0 $(($(cat res.tmp | wc -l) / 4 - 1)))
do
  let i=c*4

  readarray -t msg <<< "$(cat res.tmp | head -n $(( $i + 4 )) | tail -n 4)"

  echo ${msg[0]}
  echo ${msg[1]}
  echo -e "[$(($j)) like] [$(($j+1)) repost]\n"
  echo ${msg[2]} >> commands.tmp
  echo ${msg[3]} >> commands.tmp
  let j+=2
done

echo "type command number"
read c

if [ "$c" != "" ]
then
  eval "$(cat commands.tmp | head -n $c | tail -n 1)"
fi
Edit

Pub: 02 Oct 2023 12:10 UTC

Views: 92