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)
| 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. |