send-message: Add sending to streams and some code cleanup.
(imported from commit 806b17bd959f643a7422f9fcf5d24d6f945a18c2)
This commit is contained in:
parent
6727e9dbd9
commit
3ed6273a16
|
@ -5,7 +5,7 @@ import optparse
|
||||||
|
|
||||||
usage = """send-message [options] <recipient>
|
usage = """send-message [options] <recipient>
|
||||||
|
|
||||||
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
|
Example: send-message --site=http://127.0.0.1:8000 iago@humbughq.com
|
||||||
"""
|
"""
|
||||||
|
@ -22,13 +22,14 @@ parser.add_option('--sender',
|
||||||
dest='sender',
|
dest='sender',
|
||||||
default='othello@humbughq.com',
|
default='othello@humbughq.com',
|
||||||
action='store')
|
action='store')
|
||||||
parser.add_option('--recipient',
|
parser.add_option('--type',
|
||||||
dest='recipient',
|
dest='type',
|
||||||
|
default='private',
|
||||||
action='store')
|
action='store')
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
if len(args) != 1:
|
if len(args) == 0:
|
||||||
parser.error("Wrong number of arguments")
|
parser.error("You must specify recipients")
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
||||||
import api.common
|
import api.common
|
||||||
|
@ -38,8 +39,9 @@ client = api.common.HumbugAPI(email=options.sender,
|
||||||
site=options.site)
|
site=options.site)
|
||||||
|
|
||||||
message_data = {
|
message_data = {
|
||||||
"type": "private",
|
"type": options.type,
|
||||||
"content": "test",
|
"content": "test",
|
||||||
"to": args[0],
|
"subject": "test",
|
||||||
|
"to": args,
|
||||||
}
|
}
|
||||||
print client.send_message(message_data)
|
print client.send_message(message_data)
|
||||||
|
|
Loading…
Reference in a new issue