Add support for uploading stickers.

Closes #256
This commit is contained in:
Signal Stickers 2019-12-29 16:23:51 -05:00 committed by AsamK
parent 3f315df6c8
commit 23845eab47
6 changed files with 228 additions and 0 deletions

View file

@ -0,0 +1,36 @@
package org.asamk.signal.commands;
import net.sourceforge.argparse4j.inf.Namespace;
import net.sourceforge.argparse4j.inf.Subparser;
import org.asamk.signal.StickerPackInvalidException;
import org.asamk.signal.manager.Manager;
import java.io.IOException;
public class UploadStickerPackCommand implements LocalCommand {
@Override
public void attachToSubparser(final Subparser subparser) {
subparser.addArgument("path")
.help("The path of the manifest.json or a zip file containing the sticker pack you wish to upload.");
}
@Override
public int handleCommand(final Namespace ns, final Manager m) {
try {
String path = ns.getString("path");
String url = m.uploadStickerPack(path);
System.out.println("");
System.out.println("Upload complete! Sticker pack URL:");
System.out.println(url);
return 0;
} catch (IOException e) {
System.err.println("Upload error: " + e.getMessage());
return 3;
} catch (StickerPackInvalidException e) {
System.err.println("Invalid sticker pack: " + e.getMessage());
return 3;
}
}
}