python-zulip-api/examples/print-messages
Tim Abbott c5a140303c api: Remove hardcoded API keys from examples.
(imported from commit 64bf22298452a436d0aec796973a77f10d5e0bf9)
2012-11-26 12:25:38 -05:00

37 lines
1.1 KiB
Python
Executable file

#!/usr/bin/python
import sys
import os
import optparse
usage = """print-messages --user=<email address> [options]
Prints out each message received by the indicated user.
Example: print-messages --user=tabbott@humbughq.com --site=http://127.0.0.1:8000
"""
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=None,
action='store')
parser.add_option('--user',
dest='user',
action='store')
(options, args) = parser.parse_args()
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
import api.common
client = api.common.HumbugAPI(email=options.user,
api_key=options.api_key,
verbose=True,
site=options.site)
def print_message(message):
print message
client.call_on_each_message(print_message)