custodisco-kiosk/ssb-post.sh
2023-06-17 01:33:16 -04:00

56 lines
942 B
Bash
Executable File

#!/bin/bash
# custodisco posting
#GIVE and MINT options
## ok we need to be passed a number of arguments
## item description = $2
## image path = $3
## give to account = $4
if [ -z "$1" ]
then
echo "need arguments pls"
fi
## mint
if [ "$1" == "mint" ]
then
itemDescription=$2
itemImagePath=$3
# remove meta-data from the image and compress a bit
jpegoptim --strip-all --overwrite "$itemImagePath" --size=200k > /dev/null 2>&1
#add blob
blobID=$(cat $itemImagePath | ssb-server blobs.add) || exit 1
# publish the item
ssb-server publish . <<BLAAB
{
"type":"post",
"text":"![photo.jpg]($blobID)\\n\\n$itemDescription\\n\\n a #custodisco item ",
"custodisco":"true",
"nft": "mint",
"mentions": [
{
"name": "photo.jpg",
"type": "image/jpeg",
"link": "$blobID"
}
]
}
BLAAB
fi
## give
if [ "$1" == "give" ]
then
:
fi