paste_service#
- class PasteFile(**data)[source]#
Bases:
BaseModelA file to be pasted to the paste service.
- Parameters:
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'content': FieldInfo(annotation=str, required=True), 'lexer': FieldInfo(annotation=str, required=False, default='python'), 'name': FieldInfo(annotation=str, required=False, default='')}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class PasteResponse(**data)[source]#
Bases:
BaseModelA successful response from the paste service.
- Parameters:
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'link': FieldInfo(annotation=str, required=True), 'removal': FieldInfo(annotation=str, required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- exception PasteTooLongError[source]#
Bases:
ExceptionRaised when content is too large to upload to the paste service.
- exception PasteUnsupportedLexerError[source]#
Bases:
ExceptionRaised when an unsupported lexer is used.
- exception PasteUploadError[source]#
Bases:
ExceptionRaised when an error is encountered uploading to the paste service.
- async send_to_paste_service(*, files, http_session, paste_url='https://paste.pythondiscord.com', max_size=524288)[source]#
Upload some contents to the paste service.
- Parameters:
files (
list[PasteFile]) – The files to be uploaded to the paste service.http_session (aiohttp.ClientSession) – The session to use when POSTing the content to the paste service.
paste_url (
str) – The base url to the paste service.max_size (
int) – The max number of bytes to be allowed. Anything larger thanMAX_PASTE_SIZEwill be rejected.
- Raises:
ValueError –
max_lengthgreater than the maximum allowed by the paste service.PasteTooLongError –
contentstoo long to upload.PasteUploadError – Uploading failed.
- Return type:
- Returns:
A pydantic model containing both the URL of the paste, and a URL to remove the paste.