#!/usr/bin/env python3

import argparse
from typing import Any, Dict

usage = """print-messages [options]

Prints out each message received by the indicated bot or user.

Example: print-messages

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))
options = parser.parse_args()

client = zulip.init_from_options(options)


def print_message(message: Dict[str, Any]) -> None:
    print(message)


# This is a blocking call, and will continuously poll for new messages
client.call_on_each_message(print_message)
