From b9beaee7d427e1235802f53fa8487b7e3aaf54cd Mon Sep 17 00:00:00 2001 From: adbenitez Date: Tue, 6 Apr 2021 18:04:33 -0400 Subject: [PATCH] update `Message.new_empty()` to allow `view_type="sticker"` and also allow using message type directly (ex. `const.DC_MSG_STICKER`) so if new message types are added, they can be used direcly without needing the python API to be updated. --- python/src/deltachat/message.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python/src/deltachat/message.py b/python/src/deltachat/message.py index ad91ce97c..4587f0dd4 100644 --- a/python/src/deltachat/message.py +++ b/python/src/deltachat/message.py @@ -46,9 +46,13 @@ class Message(object): def new_empty(cls, account, view_type): """ create a non-persistent message. - :param: view_type is "text", "audio", "video", "file" + :param: view_type is the message type code or one of the strings: + "text", "audio", "video", "file", "sticker" """ - view_type_code = get_viewtype_code_from_name(view_type) + if isinstance(view_type, int): + view_type_code = view_type + else: + view_type_code = get_viewtype_code_from_name(view_type) return Message(account, ffi.gc( lib.dc_msg_new(account._dc_context, view_type_code), lib.dc_msg_unref