diff options
author | Blake DeMarcy <ofunknowndescent@gmail.com> | 2017-04-12 09:09:16 -0500 |
---|---|---|
committer | Blake DeMarcy <ofunknowndescent@gmail.com> | 2017-04-12 09:09:16 -0500 |
commit | 09077baeac68fdf4fa1178f7d410665387a74ca0 (patch) | |
tree | e8cd39673a844b197e8307eb47c175ff6c11ca95 /server.py | |
parent | 7eef803084d58b9a67736a5e67efd63ea825bd94 (diff) | |
download | bbj-09077baeac68fdf4fa1178f7d410665387a74ca0.tar.gz |
fake messages, formatting endpoint, new help menus
Diffstat (limited to 'server.py')
-rw-r--r-- | server.py | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -238,7 +238,9 @@ class API(object): def thread_load(self, args, database, user, **kwargs): """ Returns the thread object with all of its messages loaded. - Requires the argument `thread_id` + Requires the argument `thread_id`. `format` may also be + specified as a formatter to run the messages through. + Currently only "sequential" is supported. """ validate(args, ["thread_id"]) thread = db.thread_get(database, args["thread_id"]) @@ -301,6 +303,23 @@ class API(object): @api_method + def format_message(self, args, database, user, **kwargs): + """ + Requires the arguments `body` and `format`. Applies + `format` to `body` and returns the new object. See + `thread_load` for supported specifications for `format`. + """ + validate(args, ["format", "body"]) + message = [{"body": args["body"]}] + if args["format"] == "sequential": + formatter = formatting.sequential_expressions + else: + raise BBJParameterError("invalid format directive.") + formatting.apply_formatting(message, formatter) + return message[0]["body"] + + + @api_method def set_thread_pin(self, args, database, user, **kwargs): """ Requires the arguments `thread_id` and `pinned`. Pinned |