mirror of
https://github.com/chatmail/core.git
synced 2026-04-27 02:16:29 +03:00
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.
This commit is contained in:
@@ -46,9 +46,13 @@ class Message(object):
|
|||||||
def new_empty(cls, account, view_type):
|
def new_empty(cls, account, view_type):
|
||||||
""" create a non-persistent message.
|
""" 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(
|
return Message(account, ffi.gc(
|
||||||
lib.dc_msg_new(account._dc_context, view_type_code),
|
lib.dc_msg_new(account._dc_context, view_type_code),
|
||||||
lib.dc_msg_unref
|
lib.dc_msg_unref
|
||||||
|
|||||||
Reference in New Issue
Block a user