slidge.core.mixins.attachment#

Module Contents#

Classes#

Attributes#

log

class slidge.core.mixins.attachment.AttachmentMixin[source]#

Bases: slidge.core.mixins.message_maker.MessageMaker

__legacy_file_ids_to_urls[source]#
__uploaded_urls_to_sims[source]#
__uploaded_urls_to_sfs[source]#
abstract send_text(*_, **k)[source]#
async __upload(file_path, file_name=None, content_type=None)[source]#
Parameters:
  • file_path (pathlib.Path) –

  • file_name (Optional[str]) –

  • content_type (Optional[str]) –

async static __no_upload(file_path, file_name=None, legacy_file_id=None)[source]#
Parameters:
  • file_path (pathlib.Path) –

  • file_name (Optional[str]) –

  • legacy_file_id (Optional[Union[str, int]]) –

async __get_url(file_path=None, data_stream=None, data=None, file_url=None, file_name=None, content_type=None, legacy_file_id=None)[source]#
Parameters:
  • file_path (Optional[pathlib.Path]) –

  • data_stream (Optional[IO[bytes]]) –

  • data (Optional[bytes]) –

  • file_url (Optional[str]) –

  • file_name (Optional[str]) –

  • content_type (Optional[str]) –

  • legacy_file_id (Optional[Union[str, int]]) –

__set_sims(msg, uploaded_url, path, content_type=None, caption=None)[source]#
Parameters:
  • msg (slixmpp.Message) –

  • uploaded_url (str) –

  • path (pathlib.Path) –

  • content_type (Optional[str]) –

  • caption (Optional[str]) –

__set_sfs(msg, uploaded_url, path, content_type=None, caption=None)[source]#
Parameters:
  • msg (slixmpp.Message) –

  • uploaded_url (str) –

  • path (pathlib.Path) –

  • content_type (Optional[str]) –

  • caption (Optional[str]) –

__send_url(msg, legacy_msg_id, uploaded_url, caption=None, carbon=False, when=None, **kwargs)[source]#
Parameters:
  • msg (slixmpp.Message) –

  • legacy_msg_id (slidge.util.types.LegacyMessageType) –

  • uploaded_url (str) –

  • caption (Optional[str]) –

  • when (Optional[datetime.datetime]) –

async send_file(file_path=None, legacy_msg_id=None, *, data_stream=None, data=None, file_url=None, file_name=None, content_type=None, reply_to=None, when=None, caption=None, legacy_file_id=None, thread=None, **kwargs)[source]#

Send a message with an attachment

Parameters:
  • file_path (Optional[Union[pathlib.Path, str]]) – Path to the attachment

  • data_stream (Optional[IO[bytes]]) – Alternatively, a stream of bytes (such as a File object)

  • data (Optional[bytes]) – Alternatively, a bytes object

  • file_url (Optional[str]) – Alternatively, a URL

  • file_name (Optional[str]) – How the file should be named.

  • content_type (Optional[str]) – MIME type, inferred from filename if not given

  • legacy_msg_id (Optional[slidge.util.types.LegacyMessageType]) – If you want to be able to transport read markers from the gateway user to the legacy network, specify this

  • reply_to (Optional[slidge.util.types.MessageReference]) – Quote another message (XEP-0461)

  • when (Optional[datetime.datetime]) – when the file was sent, for a “delay” tag (XEP-0203)

  • caption (Optional[str]) – an optional text that is linked to the file

  • legacy_file_id (Optional[Union[str, int]]) – A unique identifier for the file on the legacy network. Plugins should try their best to provide it, to avoid duplicates.

  • thread (Optional[slidge.util.types.LegacyThreadType]) –

__send_body(body=None, legacy_msg_id=None, reply_to=None, when=None, thread=None, **kwargs)[source]#
Parameters:
async send_files(attachments, legacy_msg_id=None, body=None, *, reply_to=None, when=None, thread=None, body_first=False, correction=False, **kwargs)[source]#
Parameters:
slidge.core.mixins.attachment.log[source]#