Skip to content

Instantly share code, notes, and snippets.

@tilpner
Last active February 18, 2016 23:22
Show Gist options
  • Save tilpner/96e2688cce3281655bee to your computer and use it in GitHub Desktop.
Save tilpner/96e2688cce3281655bee to your computer and use it in GitHub Desktop.
Naive detection if a keybase user collaborates with you. POC, inefficient, perhaps broken, do not use.
#!/usr/bin/env bash
USER=`keybase status | grep Username | awk '{print $NF}'`;
COLLAB_DIR="/keybase/public/$USER/collab"
FILE=`mktemp -t "XXXXXXXXXX" -p $COLLAB_DIR`
echo $1 | keybase encrypt -b --hide-recipients $1 > $FILE
#!/usr/bin/env bash
COLLAB_DIR=/keybase/public/$1/collab
# if not present
if [ ! -d $COLLAB_DIR ]; then
echo "$1 has not setup collaboration detection"
exit 3
fi
#if empty
if [ $(find $COLLAB_DIR -maxdepth 0 -type d -empty 2>/dev/null) ]; then
echo "$1 does not collaborate with anyone"
exit 2
fi
# if filled
for f in $COLLAB_DIR/*;
do
keybase decrypt -i $f &> /dev/null
if [ $? -eq 0 ]; then
echo "$1 collaborates with you"
exit 0
fi
done
echo "$1 does not collaborate with you"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment