mostr-zulip-bot/zulip/zulip/examples/subscribe
rht 8a74f576a3 python: Remove per-file copyright notices.
These notices are redundant and obscure what are often very short
example scripts.
2020-03-23 12:52:52 -07:00

27 lines
748 B
Python
Executable file

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
import argparse
usage = """subscribe [options] --streams=<streams>
Ensures the user is subscribed to the listed streams.
Examples: subscribe --streams=foo
subscribe --streams='foo bar'
Specify your Zulip API credentials and server in a ~/.zuliprc file or using the options.
"""
import zulip
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage))
parser.add_argument('--streams', action='store', required=True)
options = parser.parse_args()
client = zulip.init_from_options(options)
print(client.add_subscriptions([{"name": stream_name} for stream_name in
options.streams.split()]))