python-zulip-api/examples/send-message
Tim Abbott 6727e9dbd9 [manual] send_message: Rename recipient/stream fields to 'to'.
This commit changes APIs and requires and update of all zephyr
mirroring bots to deploy properly.

(imported from commit 2672d2d07269379f7a865644aaeb6796d54183e1)
2012-11-15 15:30:06 -05:00

46 lines
1.3 KiB
Python
Executable file

#!/usr/bin/python
import sys
import os
import optparse
usage = """send-message [options] <recipient>
Sends a test message to the specified user.
Example: send-message --site=http://127.0.0.1:8000 iago@humbughq.com
"""
parser = optparse.OptionParser(usage=usage)
parser.add_option('--site',
dest='site',
default="https://humbughq.com",
action='store')
parser.add_option('--api-key',
dest='api_key',
default='4e5d97591bec64bf57d2698ffbb563e3',
action='store')
parser.add_option('--sender',
dest='sender',
default='othello@humbughq.com',
action='store')
parser.add_option('--recipient',
dest='recipient',
action='store')
(options, args) = parser.parse_args()
if len(args) != 1:
parser.error("Wrong number of arguments")
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
import api.common
client = api.common.HumbugAPI(email=options.sender,
api_key=options.api_key,
verbose=True,
site=options.site)
message_data = {
"type": "private",
"content": "test",
"to": args[0],
}
print client.send_message(message_data)