diff --git a/contrib/matrix_decrypt.py b/contrib/matrix_decrypt.py index 6adc8b1..8196a8e 100755 --- a/contrib/matrix_decrypt.py +++ b/contrib/matrix_decrypt.py @@ -44,6 +44,7 @@ def main(): description='Download and decrypt matrix attachments' ) parser.add_argument('url', help='the url of the attachment') + parser.add_argument('file', nargs='?', help='save attachment to ') parser.add_argument('--plumber', help='program that gets called with the ' 'dowloaded file') @@ -68,11 +69,19 @@ def main(): print("Error downloading file") return -2 - plumber = args.plumber or "/usr/bin/rifle" + plumber = args.plumber plaintext = decrypt_attachment(request.content, key, hash, iv) - file_name = save_file(plaintext) - subprocess.run([plumber, "{file}".format(file=file_name)]) + if args.file is None: + file_name = save_file(plaintext) + if plumber is None: + plumber = "/usr/bin/rifle" + else: + file_name = args.file + open(file_name, "wb").write(plaintext) + + if plumber is not None: + subprocess.run([plumber, "{file}".format(file=file_name)]) return 0