Generated by com2ann (slightly patched to avoid also converting assignment type annotations, which require Python 3.6), followed by some manual whitespace adjustment, and two fixes for use-before-define issues: - def set_zulip_client(self, zulipToJabberClient: ZulipToJabberBot) -> None: + def set_zulip_client(self, zulipToJabberClient: 'ZulipToJabberBot') -> None: -def init_from_options(options: Any, client: Optional[str] = None) -> Client: +def init_from_options(options: Any, client: Optional[str] = None) -> 'Client': Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
27 lines
640 B
Python
Executable file
27 lines
640 B
Python
Executable file
#!/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)
|