diff --git a/zulip/zulip/__init__.py b/zulip/zulip/__init__.py index 1078ffd..7fed05f 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -748,6 +748,17 @@ class Client(object): method='DELETE' ) + def update_message_flags(self, update_data): + # type: (Dict[str, Any]) -> Dict[str, Any] + ''' + See examples/update-flags for example usage. + ''' + return self.call_endpoint( + url='messages/flags', + method='POST', + request=update_data + ) + def get_message_history(self, message_id): # type: (int) -> Dict[str, Any] ''' diff --git a/zulip/zulip/examples/update-flags b/zulip/zulip/examples/update-flags new file mode 100755 index 0000000..bb47881 --- /dev/null +++ b/zulip/zulip/examples/update-flags @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import argparse + +import zulip + +usage = """update-flags (add | remove) [more_message_ids] + +Example: update-flags add read 4 8 15 +Example: update-flags remove starred 16 23 42 +""" + +parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage)) +parser.add_argument('op', choices=['add', 'remove']) +parser.add_argument('flag') +parser.add_argument('messages', type=int, nargs='+') +options = parser.parse_args() + +client = zulip.init_from_options(options) + +print(client.update_message_flags({ + 'op': options.op, + 'flag': options.flag, + 'messages': options.messages +}))