From 3ed6273a16a63d21bdd41f4e03358839cfe89034 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 14 Nov 2012 18:03:12 -0500 Subject: [PATCH] send-message: Add sending to streams and some code cleanup. (imported from commit 806b17bd959f643a7422f9fcf5d24d6f945a18c2) --- examples/send-message | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/send-message b/examples/send-message index 9b434bc..b93087f 100755 --- a/examples/send-message +++ b/examples/send-message @@ -5,7 +5,7 @@ import optparse usage = """send-message [options] -Sends a test message to the specified user. +Sends a test message to the specified recipients. Example: send-message --site=http://127.0.0.1:8000 iago@humbughq.com """ @@ -22,13 +22,14 @@ parser.add_option('--sender', dest='sender', default='othello@humbughq.com', action='store') -parser.add_option('--recipient', - dest='recipient', +parser.add_option('--type', + dest='type', + default='private', action='store') (options, args) = parser.parse_args() -if len(args) != 1: - parser.error("Wrong number of arguments") +if len(args) == 0: + parser.error("You must specify recipients") sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) import api.common @@ -38,8 +39,9 @@ client = api.common.HumbugAPI(email=options.sender, site=options.site) message_data = { - "type": "private", + "type": options.type, "content": "test", - "to": args[0], + "subject": "test", + "to": args, } print client.send_message(message_data)