diff --git a/matrixpack.sh b/matrixpack.sh index f743a267ba050d06bd673629975c1d552b64fb35..9c4f43e0c3f99d8b4c4bd806a2335751eb06c17e 100755 --- a/matrixpack.sh +++ b/matrixpack.sh @@ -141,6 +141,7 @@ do convert "$slug/tmp/$f.$type" -resize "128x128" "$slug/tmp/size" width=$(identify -format "%w" "$slug/tmp/size"[0])> /dev/null height=$(identify -format "%h" "$slug/tmp/size"[0])> /dev/null + # Appending to json echo -n "{\"body\":\"$f\",\"info\":{\"mimetype\":\"image/$type\",\"h\":$height,\"w\":$width,\"thumbnail_url\":\"$mxc\"},\"msgtype\":\"m.sticker\",\"url\":\"$mxc\",\"id\":\"$packname-$f\"}" >> "$slug/$slug.json" first="," diff --git a/updatePacks.py b/updatePacks.py index 159b50d0e33e7d5d5237ffc4dc97d73f6ca7c219..ac85991fd36ba447e500ad39df31e65901e50528 100644 --- a/updatePacks.py +++ b/updatePacks.py @@ -1,11 +1,12 @@ import json import sys +from colorama import Fore, Back, Style # Check the arguments # Pack is updated only if index and description are precised update = False if len(sys.argv) <= 1 or len(sys.argv) == 3: - print("Usage : python updatePack.py pack.json [sticker_index] [new_description]") + print("Usage : python updatePacks.py pack.json [sticker_index] [new_description]") exit(1) elif len(sys.argv) > 3: update = True @@ -23,9 +24,9 @@ if update == False: # Print the number of stickers in this pack print("There are " +str(nb_stickers) + " stickers in this pack: ") for i in range(nb_stickers): - print(str(i+1) + ". " + json_pack['stickers'][i]['body']) - print("To update one of them type:") - print("python updatePack.py " + sys.argv[1] + " sticker_index 'new_description'") + print("\t"+str(i+1) + ". " + json_pack['stickers'][i]['body']) + print("To update one of them replace the red arguments:") + print(Fore.CYAN +Style.BRIGHT + "python " +Style.RESET_ALL+ "updatePacks.py " + sys.argv[1] + Fore.RED + Style.BRIGHT+" sticker_index 'new_description'") exit(0) # Informations @@ -41,8 +42,10 @@ elif sticker_index == 0: else: json_pack['stickers'][sticker_index-1]['body'] = new_body # Print the body of all the stickers + print(Fore.GREEN + 'Updated!') + print("New sticker pack:") for i in range(nb_stickers): - print(str(i+1) + ". " + json_pack['stickers'][i]['body']) + print("\t "+str(i+1) + ". " + json_pack['stickers'][i]['body']) out_file = open(sys.argv[1], 'w') json.dump(json_pack, out_file, indent = 3)