usage: ⎗ ✓ 1 2 3 4 5 6 7 8 9 10wsconn wss://relay.nostr.band # note: query id is populated automatically wsc '["COUNT", "<QUERY_ID>", {"kinds": [41]}]' #[ # "COUNT", # "QUERY_53", # { # "count": 1831 # } #] script: ⎗ ✓ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23function wsconn(){ qid=0 WSCADDR=$1 rm wsc.out screen -L -Logfile wsc.out -dmS wsc wscat -c $1 screen -S wsc -p0 -X logfile flush 0 } function wsreconn(){ wsdisconn wsconn $WSCADDR } function wsdisconn(){ kill $(screen -ls | grep -P "\d+\.wsc\W" | grep -Po "\d+") } function wsc(){ let qid++ queryid="QUERY_$qid" query=$(echo $1 | perl -pe "s/<QUERY_ID>/$queryid/") screen -S wsc -X stuff "$query\n" match=$(tail -f wsc.out | sed "/\"$queryid\",\W$/ q") res=$(cat wsc.out | grep -F -A 100 "\"$queryid\"" | ansi2txt | tail -n +2) echo "${res:5:-2}" | jq }
Warning LINK You are about to visit a link which has been flagged with the above content warnings. Do you wish to continue? Continue Cancel