Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # stalk your vrfrens
- # more features soon™
- set -euo pipefail
- USER=$1
- KEYFILE=/tmp/vrfrens-apikey.txt
- # cache key so we don't have to grab it every time
- if [ -f $KEYFILE ]; then
- KEY=$(<$KEYFILE)
- else
- KEY=$(curl -s https://api.vrchat.cloud/api/1/config | jq .apiKey -r)
- echo $KEY > $KEYFILE
- fi
- TOKFILE=/tmp/vrfrens-tok-$USER.txt
- # also cache TOK for some time to avoid logging in if necessary. Dunno how long
- # the tokens actually last.
- if [ -f $TOKFILE ] && test $(find $TOKFILE -not -mmin +30); then
- TOK=$(<$TOKFILE)
- else
- TOK=$(curl -su $USER "https://api.vrchat.cloud/api/1/auth/user?apiKey=$KEY" | jq .authToken -r)
- echo $TOK > $TOKFILE
- fi
- FRENS=$(curl -H "Cookie: auth=$TOK" -s "https://api.vrchat.cloud/api/1/auth/user/friends?apiKey=$KEY")
- echo You have $(echo $FRENS | jq -r 'length') friends online
- echo $FRENS | jq -r 'map("\(.displayName) is in \"\(.location)\"") | join("\n")'
- OFFRENS=$(curl -H "Cookie: auth=$TOK" -s "https://api.vrchat.cloud/api/1/auth/user/friends?apiKey=$KEY&offline=true")
- echo You have $(echo $OFFRENS | jq -r 'length') friends offline:
- echo $OFFRENS | jq -r 'map(.displayName) | join("\n")'
Advertisement
Add Comment
Please, Sign In to add comment