-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
log.sh
executable file
·83 lines (74 loc) · 1.65 KB
/
log.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
usage()
{
echo "
Usage: git nostr log [options]
ex: git nostr log --publickey 0f578badfbc982c36aac5ca8ea973a0bea5ab93adaef9885e163fbe8d7e5e631 --relay ws://nostr.nostrin.gs
fetch all patches for public key and apply
Options:
--publickey nostr public key
--relay nostr relay url
"
exit 2
}
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-h | --help)
usage
;;
--publickey)
PUBLICKEY=$2
shift
shift
;;
--relay)
RELAY="$2"
shift
shift
;;
*)
PUBLICKEY="$1"
shift
;;
esac
done
if [ "$RELAY" = "" ]; then
RELAY=`git config nostr.relay`
fi
if [ "$RELAY" = "" ]; then
usage
exit 1
fi
if [ "$PUBLICKEY" = "" ]; then
PUBLICKEY=`git config nostr.publickey`
fi
if [ "$PUBLICKEY" = "" ]; then
echo "missing public key"
usage
fi
queryManifestForAuthor () {
nostril query --kinds 7777 --authors $PUBLICKEY|
websocat $RELAY|
jq -c --raw-output '.[]'|
grep "git-nostr-publish"|
tee >(jq --raw-output .id) > /dev/null
}
if [ "$PUBLICKEY" = "" ]; then
queryManifestMessageIDs
exit 0
fi
queryManifestForAuthor | grep --line-buffered .|
awk -v relay="$RELAY" '{system("nostril query -i "$1"| websocat "relay )}'|
jq '.[]'|jq -c|grep content| jq --raw-output .content|
awk '{system("echo \""$1"\" | base64 -D")}'|
jq --raw-output '.id'|
awk -v relay="$RELAY" '{system("nostril query -i "$1"| websocat "relay )}'|
grep EVENT|
jq '.[]'|
jq --raw-output -c .|
grep --line-buffered "\"content\""|
jq --raw-output .content|
grep --line-buffered .|
awk '{system("echo "$1"|base64 -d|head -n5")}'