MCPcopy Create free account
hub / github.com/chatmail/core / send_image

Method send_image

python/src/deltachat/chat.py:312–325  ·  view source on GitHub ↗

send an image message and return the resulting Message instance. :param path: path to an image file. :raises ValueError: if message can not be send/chat does not exist. :returns: the resulting :class:`deltachat.message.Message` instance

(self, path)

Source from the content-addressed store, hash-verified

310 return Message.from_db(self.account, sent_id)
311
312 def send_image(self, path):
313 """send an image message and return the resulting Message instance.
314
315 :param path: path to an image file.
316 :raises ValueError: if message can not be send/chat does not exist.
317 :returns: the resulting :class:`deltachat.message.Message` instance
318 """
319 mime_type = mimetypes.guess_type(path)[0]
320 msg = Message.new_empty(self.account, view_type="image")
321 msg.set_file(path, mime_type)
322 sent_id = lib.dc_send_msg(self.account._dc_context, self.id, msg._dc_msg)
323 if sent_id == 0:
324 raise ValueError("message could not be sent")
325 return Message.from_db(self.account, sent_id)
326
327 def set_draft(self, message):
328 """set message as draft.

Callers 2

test_message_imageMethod · 0.80

Calls 3

new_emptyMethod · 0.80
set_fileMethod · 0.80
from_dbMethod · 0.80

Tested by 2

test_message_imageMethod · 0.64