e30b3b094b
Generated by `pyupgrade --py3-plus --keep-percent-format` followed by manual indentation fixes. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
30 lines
837 B
Python
Executable file
30 lines
837 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
|
|
import zulip
|
|
|
|
usage = """send-message [options] <recipients>
|
|
|
|
Sends a test message to the specified recipients.
|
|
|
|
Example: send-message --type=stream commits --subject="my subject" --message="test message"
|
|
Example: send-message user1@example.com user2@example.com
|
|
"""
|
|
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage))
|
|
parser.add_argument('recipients', nargs='+')
|
|
parser.add_argument('--subject', default='test')
|
|
parser.add_argument('--message', default='test message')
|
|
parser.add_argument('--type', default='private')
|
|
options = parser.parse_args()
|
|
|
|
client = zulip.init_from_options(options)
|
|
|
|
message_data = {
|
|
'type': options.type,
|
|
'content': options.message,
|
|
'subject': options.subject,
|
|
'to': options.recipients,
|
|
}
|
|
print(client.send_message(message_data))
|