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

Method send_msg

python/src/deltachat/chat.py:262–282  ·  view source on GitHub ↗

send a message by using a ready Message object. :param msg: a :class:`deltachat.message.Message` instance previously returned by e.g. :meth:`deltachat.message.Message.new_empty`. :raises ValueError: if message can not be sent. :returns: a :class:`delta

(self, msg: Message)

Source from the content-addressed store, hash-verified

260 # ------ chat messaging API ------------------------------
261
262 def send_msg(self, msg: Message) -> Message:
263 """send a message by using a ready Message object.
264
265 :param msg: a :class:`deltachat.message.Message` instance
266 previously returned by
267 e.g. :meth:`deltachat.message.Message.new_empty`.
268 :raises ValueError: if message can not be sent.
269
270 :returns: a :class:`deltachat.message.Message` instance as
271 sent out. This is the same object as was passed in, which
272 has been modified with the new state of the core.
273 """
274 sent_id = lib.dc_send_msg(self.account._dc_context, self.id, msg._dc_msg)
275 if sent_id == 0:
276 raise ValueError("message could not be sent")
277 # modify message in place to avoid bad state for the caller
278 sent_msg = Message.from_db(self.account, sent_id)
279 if sent_msg is None:
280 raise ValueError("cannot load just sent message from the database")
281 msg._dc_msg = sent_msg._dc_msg
282 return msg
283
284 def send_text(self, text):
285 """send a text message and return the resulting Message instance.

Callers 8

send_and_receive_messageFunction · 0.45
test_html_messageFunction · 0.45
test_webxdc_messageFunction · 0.45
test_webxdc_huge_updateFunction · 0.45
test_reply_privatelyFunction · 0.45
test_quote_attachmentFunction · 0.45
test_group_quoteFunction · 0.45

Calls 1

from_dbMethod · 0.80

Tested by 8

send_and_receive_messageFunction · 0.36
test_html_messageFunction · 0.36
test_webxdc_messageFunction · 0.36
test_webxdc_huge_updateFunction · 0.36
test_reply_privatelyFunction · 0.36
test_quote_attachmentFunction · 0.36
test_group_quoteFunction · 0.36