forked from g1n/twtxt-c
added support for registries
This commit is contained in:
parent
7fd588170a
commit
3a9def3c56
62
twtxt-c
62
twtxt-c
|
@ -26,13 +26,22 @@ Commands:
|
||||||
tweet Append a new tweet to your twtxt file.
|
tweet Append a new tweet to your twtxt file.
|
||||||
unfollow Remove an existing source from your...
|
unfollow Remove an existing source from your...
|
||||||
view Show feed of given source.
|
view Show feed of given source.
|
||||||
registry Show registers\n
|
|
||||||
reg list Show registers
|
reg list Show registers
|
||||||
reg add Add your twtxt to registry
|
reg add Add your twtxt to registry
|
||||||
reg users List users on the registry
|
reg users List users on the registry
|
||||||
|
reg twts Fetch recent tweets from registry
|
||||||
|
reg mentions search for mentions by url
|
||||||
|
reg tag Search for tags
|
||||||
"
|
"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
read_config () {
|
||||||
|
declare -A v=()
|
||||||
|
while read -r var value; do
|
||||||
|
v[$var]=$value
|
||||||
|
done < $config/registry
|
||||||
|
}
|
||||||
case $1 in
|
case $1 in
|
||||||
-h | --help)
|
-h | --help)
|
||||||
usage; exit ;;
|
usage; exit ;;
|
||||||
|
@ -50,7 +59,7 @@ case $1 in
|
||||||
read -p "URL to twtxt [https://example.com/twtxt.txt]: " url
|
read -p "URL to twtxt [https://example.com/twtxt.txt]: " url
|
||||||
url=${url:-"https://example.com/twtxt.txt"}
|
url=${url:-"https://example.com/twtxt.txt"}
|
||||||
printf "[twtxt]\n nick = %s\n twtfile = %s\n url = %s\n" "$nick" "$path_to_twtxt" "$url" >> $config/config
|
printf "[twtxt]\n nick = %s\n twtfile = %s\n url = %s\n" "$nick" "$path_to_twtxt" "$url" >> $config/config
|
||||||
printf "https://twtxt.envs.net/api/plain/\n https://twtxt.tilde.institute/api/plain/" > $config/registry
|
printf "https://twtxt.envs.net/api/plain/\nhttps://twtxt.tilde.institute/api/plain/\n" > $config/registry
|
||||||
;;
|
;;
|
||||||
tweet)
|
tweet)
|
||||||
export config=/home/$USER/.config/twtxt-c/config
|
export config=/home/$USER/.config/twtxt-c/config
|
||||||
|
@ -59,16 +68,51 @@ case $1 in
|
||||||
view)
|
view)
|
||||||
curl $2 2>/dev/null | grep -v "#" | awk 'BEGIN { FS = "\t" } ; {print $2}'
|
curl $2 2>/dev/null | grep -v "#" | awk 'BEGIN { FS = "\t" } ; {print $2}'
|
||||||
;;
|
;;
|
||||||
*)
|
|
||||||
printf "Work in progress\n" ;;
|
|
||||||
reg)
|
reg)
|
||||||
case $2 in
|
case $2 in
|
||||||
list | *)
|
list)
|
||||||
cat /home/$USER/twtxt-c/registry
|
cat /home/$USER/.config/twtxt-c/registry
|
||||||
;;
|
;;
|
||||||
add)
|
add)
|
||||||
url=
|
config=/home/$USER/.config/twtxt-c/
|
||||||
curl -X POST 'https://twtxt.tilde.institute/api/plain/users?url=&nickname='
|
declare -A v=()
|
||||||
|
while read -r line; do
|
||||||
|
var=$(echo $line | awk '{print $1}' )
|
||||||
|
value=$(echo $line | awk '{print $3}' )
|
||||||
|
v[$var]=$value
|
||||||
|
done < $config/config
|
||||||
|
req="https://twtxt.tilde.institute/api/plain/users?url=${v[url]}&nickname=${v[nick]}"
|
||||||
|
req2="https://twtxt.envs.net/api/plain/users?url=${v[url]}&nickname=${v[nick]}"
|
||||||
|
echo "post these requests:"
|
||||||
|
echo "curl -X POST $req"
|
||||||
|
echo "curl -X POST $req2"
|
||||||
|
#curl -X POST $req
|
||||||
|
#curl -X POST $req2
|
||||||
|
# I have commented the actual curl request so that I accidentally re-register myself during testing
|
||||||
|
;;
|
||||||
|
users)
|
||||||
|
curl 'https://twtxt.tilde.institute/api/plain/users'
|
||||||
|
curl 'https://twtxt.envs.net/api/plain/users' ;;
|
||||||
|
twts)
|
||||||
|
curl 'https://twtxt.tilde.institute/api/plain/tweets'
|
||||||
|
curl 'https://twtxt.envs.net/api/plain/tweets'
|
||||||
|
;;
|
||||||
|
mentions)
|
||||||
|
url=$3
|
||||||
|
req="https://twtxt.tilde.institute/api/plain/mentions?url=$url"
|
||||||
|
req2="https://twtxt.envs.net/api/plain/mentions?url=$url"
|
||||||
|
curl $req
|
||||||
|
curl $req2
|
||||||
|
;;
|
||||||
|
tag)
|
||||||
|
tag=$3
|
||||||
|
req="https://twtxt.tilde.institute/api/plain/tags/$tag"
|
||||||
|
req2="https://twtxt.envs.net/api/plain/tags/$tag"
|
||||||
|
curl $req
|
||||||
|
curl $req2
|
||||||
|
;;
|
||||||
|
esac ;;
|
||||||
|
*)
|
||||||
|
printf "Work in progress\n" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue