yuyo.pagination#
Utilities used for quick pagination handling within reaction and component executors.
BLACK_CROSS module-attribute
#
BLACK_CROSS: typing.Final[hikari.UnicodeEmoji] = hikari.UnicodeEmoji('✖️')
The emoji used to close a menu in a component context.
EntryT module-attribute
#
EntryT = typing.Union[tuple[hikari.UndefinedOr[str], hikari.UndefinedOr[hikari.Embed]], 'Page']
A type hint used to represent a paginator entry.
This may be either Page or tuple[hikari.UndefinedOr[str], hikari.UndefinedOr[hikari.Embed]]
where tuple[0] is the message content and tuple[1] is an embed to send.
LEFT_DOUBLE_TRIANGLE module-attribute
#
LEFT_DOUBLE_TRIANGLE: typing.Final[hikari.UnicodeEmoji] = hikari.UnicodeEmoji('⏮️')
The emoji used to go back to the first entry.
LEFT_TRIANGLE module-attribute
#
LEFT_TRIANGLE: typing.Final[hikari.UnicodeEmoji] = hikari.UnicodeEmoji('◀️')
The emoji used to go back an entry.
RIGHT_DOUBLE_TRIANGLE module-attribute
#
RIGHT_DOUBLE_TRIANGLE: typing.Final[hikari.UnicodeEmoji] = hikari.UnicodeEmoji('⏭️')
The emoji used for the (not enabled by default) skip to last entry button.
RIGHT_TRIANGLE module-attribute
#
RIGHT_TRIANGLE: typing.Final[hikari.UnicodeEmoji] = hikari.UnicodeEmoji('▶️')
The emoji used to continue to the next entry.
STOP_SQUARE module-attribute
#
STOP_SQUARE: typing.Final[hikari.UnicodeEmoji] = hikari.UnicodeEmoji('⏹️')
The emoji used to close a menu in a reaction context.
Page #
Represents a pagianted response.
__init__ #
__init__(content=hikari.UNDEFINED, *, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED)
Initialise a response page.
Parameters:
- content (
typing.Union[str, Embed, Resourceish, UndefinedType]
, default:UNDEFINED
) –The message content to send.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead be treated as an embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. - attachment (
hikari.UndefinedOr[hikari.Resourceish]
, default:UNDEFINED
) –A singular attachment to send.
- attachments (
hikari.UndefinedOr[abc.Sequence[hikari.Resourceish]]
, default:UNDEFINED
) –Up to 10 attachments to include in the response.
- embed (
hikari.UndefinedOr[hikari.Embed]
, default:UNDEFINED
) –A singular embed to send.
- embeds (
hikari.UndefinedOr[abc.Sequence[hikari.Embed]]
, default:UNDEFINED
) –Up to 10 embeds to include in the response.
Raises:
-
ValueError
–Raised for any of the following reasons:
- When both
attachment
andattachments
are provided. - When both
embed
andembeds
are passed.
- When both
from_entry classmethod
#
from_entry(entry)
Paginator #
Standard implementation of a paginator.
To use this with components or reactions see the following classes:
has_finished_iterating property
#
has_finished_iterating: bool
Whether this has finished iterating over the original iterator.
__init__ #
__init__(iterator)
Initialise a paginator.
Parameters:
- iterator (
abc.Iterator[yuyo.pagination.EntryT] | abc.AsyncIterator[yuyo.pagination.EntryT]
) –The iterator to paginate.
This should be an iterator of Pages.
jump_to_first #
jump_to_first()
jump_to_last async
#
jump_to_last()
step_back #
step_back()
aenumerate async
#
aenumerate(iterable)
async_paginate_string async
#
async_paginate_string(lines, /, *, char_limit=2000, line_limit=25, wrapper=None)
Lazily paginate an iterator of lines.
Parameters:
- lines (
abc.AsyncIterable[str]
) –The asynchronous iterator of lines to paginate.
- char_limit (
int
, default:2000
) –The limit for how many characters should be included per yielded page.
- line_limit (
int
, default:25
) –The limit for how many lines should be included per yielded page.
- wrapper (
typing.Optional[str]
, default:None
) –A wrapper for each yielded page. This should leave "{}" in it to be replaced by the page's content.
Returns:
paginate_string #
paginate_string(lines, /, *, char_limit=2000, line_limit=25, wrapper=None)
Lazily paginate an iterator of lines.
Parameters:
- lines (
abc.abc.Iterator[str] | abc.abc.AsyncIterator[str]
) –The iterator of lines to paginate. This iterator may be asynchronous or synchronous.
- char_limit (
int
, default:2000
) –The limit for how many characters should be included per yielded page.
- line_limit (
int
, default:25
) –The limit for how many lines should be included per yielded page.
- wrapper (
typing.Optional[str]
, default:None
) –A wrapper for each yielded page. This should leave "{}" in it to be replaced by the page's content.
Returns:
sync_paginate_string #
sync_paginate_string(lines, /, *, char_limit=2000, line_limit=25, wrapper=None)
Lazily paginate an iterator of lines.
Parameters:
- lines (
abc.Iterable[str]
) –The iterator of lines to paginate.
- char_limit (
int
, default:2000
) –The limit for how many characters should be included per yielded page.
- line_limit (
int
, default:25
) –The limit for how many lines should be included per yielded page.
- wrapper (
typing.Optional[str]
, default:None
) –A wrapper for each yielded page. This should leave "{}" in it to be replaced by the page's content.
Returns: