You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created a simple bash script for my use to generate sticker packs automatically.
The output of it is a folder containing a json of uploaded images in current folder, a readme containing a preview and the preview image generated with imagemagick (to be shared on git repos).
However, that's not clean code, it's kinda hardcoded (ex width/height fixed, some infos missing in json, mimetype etc.) but it doesn't affect element when using it.
#!/bin/bash# usage# matrixpack token homeserver## pack name is the folder name# sticker name is the file name# /!\ token is sensitive informationiftest$#!= 2 ;thenecho1>&2"$0:FATAL: $# invalid argument number (expected 2)"exit 1
fi
dir=$(pwd)
token=$1
packname=${dir##*/}
homeserver=$2echo -e "Creating sticker pack\ndir=$dir\npackname=$packname"
json="{\"title\":\"$packname\",\"id\":\"$packname\",\"stickers\":["
first=0
forfin*doiftest$first!= 1 ;then
first=1
else json="$json,"fi
mxc=$(curl -X POST -H "Content-Type: image/png" --data-binary "@$f""https://$homeserver/_matrix/media/r0/upload?access_token=$token"| python3 -c "import sys, json; print(json.load(sys.stdin)['content_uri'])")
json="$json{\"body\":\"$f\",\"info\":{\"h\":128,\"w\":128,\"thumbnail_url\":\"$mxc\"},\"msgtype\":\"m.sticker\",\"url\":\"$mxc\",\"id\":\"$f\"}"done
montage *"preview.png"
mkdir "$packname"
mv "preview.png""$packname"echo -e "### $packname \n![Preview of $packname](preview.png)">"$packname/README.md"echo -n "$json]}">"$packname/$packname.json"
In addition to telegram import, there should be some easy way to create new sticker packs.
Somewhat related to #7
The text was updated successfully, but these errors were encountered: