list nostr events, like and repost from bash

dependencies:

usage:

./noscmd.sh <npub> <limit>

script:

dir=$(dirname "${BASH_SOURCE[0]}")
rm -f "$dir/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)

rows=4
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 + ")"' > "$dir/res.tmp"

let j=1
for c in $(seq 0 $(($(cat "$dir/res.tmp" | wc -l) / $rows - 1)))
do
  let i=c*$rows
  readarray -t msg <<< "$(cat $dir/res.tmp | head -n $(( $i + $rows )) | tail -n $rows)"

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

echo "type command number"
read c

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

bashrc install:

echo 'alias noscmd="$HOME/noscmd.sh"' >> $HOME/.bashrc
source $HOME/.bashrc
Edit

Pub: 03 Oct 2023 13:10 UTC

Edit: 03 Oct 2023 13:24 UTC

Views: 604