From c9abff751e8818c6438bce6fe80f49e3eba8084b Mon Sep 17 00:00:00 2001 From: ChrisLovering Date: Sat, 16 Jul 2022 21:26:00 +0000 Subject: Deploying to docs from @ python-discord/bot-core@c448b69160e287826268db6f499eef81c4005e5a 🚀 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v7.3.0/output/botcore.async_stats.html | 389 +++++++++++++++++ v7.3.0/output/botcore.exts.html | 354 ++++++++++++++++ v7.3.0/output/botcore.html | 584 ++++++++++++++++++++++++++ v7.3.0/output/botcore.site_api.html | 525 +++++++++++++++++++++++ v7.3.0/output/botcore.utils.caching.html | 402 ++++++++++++++++++ v7.3.0/output/botcore.utils.channel.html | 402 ++++++++++++++++++ v7.3.0/output/botcore.utils.html | 423 +++++++++++++++++++ v7.3.0/output/botcore.utils.interactions.html | 422 +++++++++++++++++++ v7.3.0/output/botcore.utils.logging.html | 400 ++++++++++++++++++ v7.3.0/output/botcore.utils.members.html | 388 +++++++++++++++++ v7.3.0/output/botcore.utils.regex.html | 384 +++++++++++++++++ v7.3.0/output/botcore.utils.scheduling.html | 509 ++++++++++++++++++++++ 12 files changed, 5182 insertions(+) create mode 100644 v7.3.0/output/botcore.async_stats.html create mode 100644 v7.3.0/output/botcore.exts.html create mode 100644 v7.3.0/output/botcore.html create mode 100644 v7.3.0/output/botcore.site_api.html create mode 100644 v7.3.0/output/botcore.utils.caching.html create mode 100644 v7.3.0/output/botcore.utils.channel.html create mode 100644 v7.3.0/output/botcore.utils.html create mode 100644 v7.3.0/output/botcore.utils.interactions.html create mode 100644 v7.3.0/output/botcore.utils.logging.html create mode 100644 v7.3.0/output/botcore.utils.members.html create mode 100644 v7.3.0/output/botcore.utils.regex.html create mode 100644 v7.3.0/output/botcore.utils.scheduling.html (limited to 'v7.3.0/output') diff --git a/v7.3.0/output/botcore.async_stats.html b/v7.3.0/output/botcore.async_stats.html new file mode 100644 index 00000000..25af2832 --- /dev/null +++ b/v7.3.0/output/botcore.async_stats.html @@ -0,0 +1,389 @@ + + + + + + + + + async_stats - Bot Core v7.3.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+
+ +
+ +
+
+
+

async_stats#

+

An async transport method for statsd communication.

+
+
+class AsyncStatsClient(loop, host='localhost', port=8125, prefix=None)[source]#
+

Bases: StatsClientBase

+

An async implementation of statsd.client.base.StatsClientBase that supports async stat communication.

+
+
+__init__(loop, host='localhost', port=8125, prefix=None)[source]#
+

Create a new AsyncStatsClient.

+
+
Parameters:
+
+
+
+
+ +
+
+async create_socket()[source]#
+

Use asyncio.loop.create_datagram_endpoint from the loop given on init to create a socket.

+
+
Return type:
+

None

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/v7.3.0/output/botcore.exts.html b/v7.3.0/output/botcore.exts.html new file mode 100644 index 00000000..8c513cb0 --- /dev/null +++ b/v7.3.0/output/botcore.exts.html @@ -0,0 +1,354 @@ + + + + + + + + + Exts - Bot Core v7.3.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+
+ +
+ +
+
+
+

Exts#

+

Reusable Discord cogs.

+
+ +
+
+ +
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/v7.3.0/output/botcore.html b/v7.3.0/output/botcore.html new file mode 100644 index 00000000..db8223c8 --- /dev/null +++ b/v7.3.0/output/botcore.html @@ -0,0 +1,584 @@ + + + + + + + + + Botcore - Bot Core v7.3.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+
+ +
+ +
+
+
+

Botcore#

+

Useful utilities and tools for Discord bot development.

+
+
+class BotBase(*args, guild_id, allowed_roles, http_session, redis_session=None, api_client=None, statsd_url=None, **kwargs)[source]#
+

Bases: Bot

+

A sub-class that implements many common features that Python Discord bots use.

+
+
+__init__(*args, guild_id, allowed_roles, http_session, redis_session=None, api_client=None, statsd_url=None, **kwargs)[source]#
+

Initialise the base bot instance.

+
+
Parameters:
+
+
+
+
+ +
+
+async add_cog(cog)[source]#
+

Add the given cog to the bot and log the operation.

+
+
Return type:
+

None

+
+
+
+ +
+
+add_command(command)[source]#
+

Add command as normal and then add its root aliases to the bot.

+
+
Return type:
+

None

+
+
+
+ +
+
+clear()[source]#
+

Not implemented! Re-instantiate the bot instead of attempting to re-use a closed one.

+
+
Return type:
+

None

+
+
+
+ +
+
+async close()[source]#
+

Close the Discord connection, and the aiohttp session, connector, statsd client, and resolver.

+
+
Return type:
+

None

+
+
+
+ +
+
+async load_extensions(module)[source]#
+

Load all the extensions within the given module and save them to self.all_extensions.

+

This should be ran in a task on the event loop to avoid deadlocks caused by wait_for calls.

+
+
Return type:
+

None

+
+
+
+ +
+
+async log_to_dev_log(message)[source]#
+

Log the given message to #dev-log.

+
+
Return type:
+

None

+
+
+
+ +
+
+async on_guild_available(guild)[source]#
+

Set the internal guild available event when self.guild_id becomes available.

+

If the cache appears to still be empty (no members, no channels, or no roles), the event +will not be set and guild_available_but_cache_empty event will be emitted.

+
+
Return type:
+

None

+
+
+
+ +
+
+async on_guild_unavailable(guild)[source]#
+

Clear the internal guild available event when self.guild_id becomes unavailable.

+
+
Return type:
+

None

+
+
+
+ +
+
+async ping_services()[source]#
+

Ping all required services on setup to ensure they are up before starting.

+
+
Return type:
+

None

+
+
+
+ +
+
+remove_command(name)[source]#
+

Remove a command/alias as normal and then remove its root aliases from the bot.

+

Individual root aliases cannot be removed by this function. +To remove them, either remove the entire command or manually edit bot.all_commands.

+
+
Return type:
+

Optional[Command]

+
+
+
+ +
+
+async setup_hook()[source]#
+

An async init to startup generic services.

+

Connects to statsd, and calls +AsyncStatsClient.create_socket +and ping_services().

+
+
Return type:
+

None

+
+
+
+ +
+
+async wait_until_guild_available()[source]#
+

Wait until the guild that matches the guild_id given at init is available (and the cache is ready).

+

The on_ready event is inadequate because it only waits 2 seconds for a GUILD_CREATE +gateway event before giving up and thus not populating the cache for unavailable guilds.

+
+
Return type:
+

None

+
+
+
+ +
+ +
+
+exception StartupError(base)[source]#
+

Bases: Exception

+

Exception class for startup errors.

+
+
+__init__(base)[source]#
+
+ +
+ +
+

Subpackages#

+ +
+
+

Submodules#

+ +
+
+ +
+
+ +
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/v7.3.0/output/botcore.site_api.html b/v7.3.0/output/botcore.site_api.html new file mode 100644 index 00000000..2fef8cd4 --- /dev/null +++ b/v7.3.0/output/botcore.site_api.html @@ -0,0 +1,525 @@ + + + + + + + + + site_api - Bot Core v7.3.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+
+ +
+ +
+
+
+

site_api#

+

An API wrapper around the Site API.

+
+
+class APIClient(site_api_url, site_api_token, **session_kwargs)[source]#
+

Bases: object

+

A wrapper for the Django Site API.

+
+
+__init__(site_api_url, site_api_token, **session_kwargs)[source]#
+

Initialize a new APIClient instance.

+
+
Parameters:
+
    +
  • site_api_url (str) – The URL of the site API.

  • +
  • site_api_token (str) – The token to use for authentication.

  • +
  • session_kwargs – Keyword arguments to pass to the aiohttp.ClientSession constructor.

  • +
+
+
+
+ +
+
+async close()[source]#
+

Close the aiohttp session.

+
+
Return type:
+

None

+
+
+
+ +
+
+async delete(endpoint, *, raise_for_status=True, **kwargs)[source]#
+

Send a DELETE request to the site API and return the JSON response.

+
+
Parameters:
+
    +
  • endpoint (str) – The endpoint to send the request to.

  • +
  • raise_for_status (bool) – Whether or not to raise an exception if the response is not OK.

  • +
  • **kwargs – Any extra keyword arguments to pass to aiohttp.request().

  • +
+
+
Return type:
+

Optional[dict]

+
+
Returns:
+

The JSON response the API returns, or None if the response is 204 No Content.

+
+
+
+ +
+
+async get(endpoint, *, raise_for_status=True, **kwargs)[source]#
+

Equivalent to APIClient.request() with GET passed as the method.

+
+
Return type:
+

dict

+
+
+
+ +
+
+async static maybe_raise_for_status(response, should_raise)[source]#
+

Raise ResponseCodeError for non-OK response if an exception should be raised.

+
+
Parameters:
+
+
+
Raises:
+

ResponseCodeError – If the response is not OK and should_raise is True.

+
+
Return type:
+

None

+
+
+
+ +
+
+async patch(endpoint, *, raise_for_status=True, **kwargs)[source]#
+

Equivalent to APIClient.request() with PATCH passed as the method.

+
+
Return type:
+

dict

+
+
+
+ +
+
+async post(endpoint, *, raise_for_status=True, **kwargs)[source]#
+

Equivalent to APIClient.request() with POST passed as the method.

+
+
Return type:
+

dict

+
+
+
+ +
+
+async put(endpoint, *, raise_for_status=True, **kwargs)[source]#
+

Equivalent to APIClient.request() with PUT passed as the method.

+
+
Return type:
+

dict

+
+
+
+ +
+
+async request(method, endpoint, *, raise_for_status=True, **kwargs)[source]#
+

Send an HTTP request to the site API and return the JSON response.

+
+
Parameters:
+
    +
  • method (str) – The HTTP method to use.

  • +
  • endpoint (str) – The endpoint to send the request to.

  • +
  • raise_for_status (bool) – Whether or not to raise an exception if the response is not OK.

  • +
  • **kwargs – Any extra keyword arguments to pass to aiohttp.request().

  • +
+
+
Return type:
+

dict

+
+
Returns:
+

The JSON response the API returns.

+
+
Raises:
+

ResponseCodeError – If the response is not OK and raise_for_status is True.

+
+
+
+ +
+ +
+
+exception ResponseCodeError(response, response_json=None, response_text=None)[source]#
+

Bases: ValueError

+

Raised in APIClient.request() when a non-OK HTTP response is received.

+
+
+__init__(response, response_json=None, response_text=None)[source]#
+

Initialize a new ResponseCodeError instance.

+
+
Parameters:
+
    +
  • response (aiohttp.ClientResponse) – The response object from the request.

  • +
  • response_json (Optional[dict]) – The JSON response returned from the request, if any.

  • +
  • response_text (Optional[str]) – The text of the request, if any.

  • +
+
+
+
+ +
+
+__str__()[source]#
+

Return a string representation of the error.

+
+ +
+ +
+ +
+
+ +
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/v7.3.0/output/botcore.utils.caching.html b/v7.3.0/output/botcore.utils.caching.html new file mode 100644 index 00000000..8db21c68 --- /dev/null +++ b/v7.3.0/output/botcore.utils.caching.html @@ -0,0 +1,402 @@ + + + + + + + + + caching - Bot Core v7.3.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+
+ +
+ +
+
+
+

caching#

+

Utilities related to custom caches.

+
+
+class AsyncCache(max_size=128)[source]#
+

Bases: object

+

LRU cache implementation for coroutines.

+

Once the cache exceeds the maximum size, keys are deleted in FIFO order.

+

An offset may be optionally provided to be applied to the coroutine’s arguments when creating the cache key.

+
+
+__call__(arg_offset=0)[source]#
+

Decorator for async cache.

+
+
Parameters:
+

arg_offset (int) – The offset for the position of the key argument.

+
+
Return type:
+

Callable

+
+
Returns:
+

A decorator to wrap the target function.

+
+
+
+ +
+
+__init__(max_size=128)[source]#
+

Initialise a new AsyncCache instance.

+
+
Parameters:
+

max_size (int) – How many items to store in the cache.

+
+
+
+ +
+
+clear()[source]#
+

Clear cache instance.

+
+
Return type:
+

None

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/v7.3.0/output/botcore.utils.channel.html b/v7.3.0/output/botcore.utils.channel.html new file mode 100644 index 00000000..8b5711c4 --- /dev/null +++ b/v7.3.0/output/botcore.utils.channel.html @@ -0,0 +1,402 @@ + + + + + + + + + channel - Bot Core v7.3.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+
+ +
+ +
+
+
+

channel#

+

Useful helper functions for interacting with various discord channel objects.

+
+
+async get_or_fetch_channel(bot, channel_id)[source]#
+

Attempt to get or fetch the given channel_id from the bots cache, and return it.

+
+
Parameters:
+
+
+
Raises:
+
+
+
Return type:
+

GuildChannel

+
+
Returns:
+

The channel from the ID.

+
+
+
+ +
+
+is_in_category(channel, category_id)[source]#
+

Return whether the given channel in the the category with the id category_id.

+
+
Parameters:
+
    +
  • channel (TextChannel) – The channel to check.

  • +
  • category_id (int) – The category to check for.

  • +
+
+
Return type:
+

bool

+
+
Returns:
+

A bool depending on whether the channel is in the category.

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/v7.3.0/output/botcore.utils.html b/v7.3.0/output/botcore.utils.html new file mode 100644 index 00000000..9575e738 --- /dev/null +++ b/v7.3.0/output/botcore.utils.html @@ -0,0 +1,423 @@ + + + + + + + + + Utils - Bot Core v7.3.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+
+ +
+ +
+
+
+

Utils#

+

Useful utilities and tools for Discord bot development.

+
+
+apply_monkey_patches()[source]#
+

Applies all common monkey patches for our bots.

+
+
Patches discord.ext.commands.Command and discord.ext.commands.Group to support root aliases.

A root_aliases keyword argument is added to these two objects, which is a sequence of alias names +that will act as top-level groups rather than being aliases of the command’s group.

+

It’s stored as an attribute also named root_aliases

+
+
Patches discord’s internal send_typing method so that it ignores 403 errors from Discord.

When under heavy load Discord has added a CloudFlare worker to this route, which causes 403 errors to be thrown.

+
+
+
+
Return type:
+

None

+
+
+
+ +
+
+unqualify(name)[source]#
+

Return an unqualified name given a qualified module/package name.

+
+
Parameters:
+

name (str) – The module name to unqualify.

+
+
Return type:
+

str

+
+
Returns:
+

The unqualified module name.

+
+
+
+ +
+

Submodules#

+ +
+
+ +
+
+ +
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/v7.3.0/output/botcore.utils.interactions.html b/v7.3.0/output/botcore.utils.interactions.html new file mode 100644 index 00000000..4101c45f --- /dev/null +++ b/v7.3.0/output/botcore.utils.interactions.html @@ -0,0 +1,422 @@ + + + + + + + + + interactions - Bot Core v7.3.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+
+ +
+ +
+
+
+

interactions#

+
+
+class DeleteMessageButton(*, style=<ButtonStyle.secondary: 2>, label='Delete', **kwargs)[source]#
+

Bases: Button

+

A button that can be added to a view to delete the message containing the view on click.

+

This button itself carries out no interaction checks, these should be done by the parent view.

+

See botcore.utils.interactions.ViewWithUserAndRoleCheck for a view that implements basic checks.

+
+
Parameters:
+
    +
  • style (ButtonStyle) – The style of the button, set to ButtonStyle.secondary if not specified.

  • +
  • label (str) – The label of the button, set to “Delete” if not specified.

  • +
+
+
+
+
+__init__(*, style=<ButtonStyle.secondary: 2>, label='Delete', **kwargs)[source]#
+
+ +
+
+async callback(interaction)[source]#
+

Delete the original message on button click.

+
+
Return type:
+

None

+
+
+
+ +
+ +
+
+class ViewWithUserAndRoleCheck(*, allowed_users, allowed_roles, timeout=180.0)[source]#
+

Bases: View

+

A view that allows the original invoker and moderators to interact with it.

+
+
Parameters:
+
    +
  • allowed_users (Sequence[int]) – A sequence of user’s ids who are allowed to interact with the view.

  • +
  • allowed_roles (Sequence[int]) – A sequence of role ids that are allowed to interact with the view.

  • +
  • timeout (Optional[float]) – Timeout in seconds from last interaction with the UI before no longer accepting input. +If None then there is no timeout.

  • +
+
+
+
+
+__init__(*, allowed_users, allowed_roles, timeout=180.0)[source]#
+
+ +
+
+async interaction_check(interaction)[source]#
+

Ensure the user clicking the button is the view invoker, or a moderator.

+
+
Parameters:
+

interaction (Interaction) – The interaction that occurred.

+
+
Return type:
+

bool

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/v7.3.0/output/botcore.utils.logging.html b/v7.3.0/output/botcore.utils.logging.html new file mode 100644 index 00000000..08bc153a --- /dev/null +++ b/v7.3.0/output/botcore.utils.logging.html @@ -0,0 +1,400 @@ + + + + + + + + + logging - Bot Core v7.3.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+
+ +
+ +
+
+
+

logging#

+

Common logging related functions.

+
+
+class CustomLogger(name, level=0)[source]#
+

Bases: Logger

+

Custom implementation of the logging.Logger class with an added trace method.

+
+
+trace(msg, *args, **kwargs)[source]#
+

Log the given message with the severity "TRACE".

+

To pass exception information, use the keyword argument exc_info with a true value:

+
logger.trace("Houston, we have an %s", "interesting problem", exc_info=1)
+
+
+
+
Parameters:
+
    +
  • msg (str) – The message to be logged.

  • +
  • args – Passed to the base log function as is.

  • +
  • kwargs – Passed to the base log function as is.

  • +
+
+
Return type:
+

None

+
+
+
+ +
+ +
+
+get_logger(name=None)[source]#
+

Utility to make mypy recognise that logger is of type CustomLogger.

+
+
Parameters:
+

name (Optional[str]) – The name given to the logger.

+
+
Return type:
+

CustomLogger

+
+
Returns:
+

An instance of the CustomLogger class.

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/v7.3.0/output/botcore.utils.members.html b/v7.3.0/output/botcore.utils.members.html new file mode 100644 index 00000000..4ef897e0 --- /dev/null +++ b/v7.3.0/output/botcore.utils.members.html @@ -0,0 +1,388 @@ + + + + + + + + + members - Bot Core v7.3.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+
+ +
+ +
+
+
+

members#

+

Useful helper functions for interactin with discord.Member objects.

+
+
+async get_or_fetch_member(guild, member_id)[source]#
+

Attempt to get a member from cache; on failure fetch from the API.

+
+
Return type:
+

Optional[Member]

+
+
Returns:
+

The discord.Member or None to indicate the member could not be found.

+
+
+
+ +
+
+async handle_role_change(member, coro, role)[source]#
+

Await the given coro with role as the sole argument.

+

Handle errors that we expect to be raised from +discord.Member.add_roles and discord.Member.remove_roles.

+
+
Parameters:
+
+
+
Return type:
+

None

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/v7.3.0/output/botcore.utils.regex.html b/v7.3.0/output/botcore.utils.regex.html new file mode 100644 index 00000000..4e490dbf --- /dev/null +++ b/v7.3.0/output/botcore.utils.regex.html @@ -0,0 +1,384 @@ + + + + + + + + + regex - Bot Core v7.3.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+
+ +
+ +
+
+
+

regex#

+

Common regular expressions.

+
+
+DISCORD_INVITE[source]#
+

Regex for Discord server invites.

+
+

Warning

+

This regex pattern will capture until a whitespace, if you are to use the ‘invite’ capture group in +any HTTP requests or similar. Please ensure you sanitise the output using something +such as urllib.parse.quote().

+
+
+
+
+ +
+
+FORMATTED_CODE_REGEX[source]#
+

Regex for formatted code, using Discord’s code blocks.

+
+
+
+ +
+
+RAW_CODE_REGEX[source]#
+

Regex for raw code, not using Discord’s code blocks.

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/v7.3.0/output/botcore.utils.scheduling.html b/v7.3.0/output/botcore.utils.scheduling.html new file mode 100644 index 00000000..b671fdf9 --- /dev/null +++ b/v7.3.0/output/botcore.utils.scheduling.html @@ -0,0 +1,509 @@ + + + + + + + + + scheduling - Bot Core v7.3.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+
+ +
+ +
+
+
+

scheduling#

+

Generic python scheduler.

+
+
+class Scheduler(name)[source]#
+

Bases: object

+

Schedule the execution of coroutines and keep track of them.

+

When instantiating a Scheduler, a name must be provided. This name is used to distinguish the +instance’s log messages from other instances. Using the name of the class or module containing +the instance is suggested.

+

Coroutines can be scheduled immediately with schedule or in the future with schedule_at +or schedule_later. A unique ID is required to be given in order to keep track of the +resulting Tasks. Any scheduled task can be cancelled prematurely using cancel by providing +the same ID used to schedule it.

+

The in operator is supported for checking if a task with a given ID is currently scheduled.

+

Any exception raised in a scheduled task is logged when the task is done.

+
+
+__contains__(task_id)[source]#
+

Return True if a task with the given task_id is currently scheduled.

+
+
Parameters:
+

task_id (Hashable) – The task to look for.

+
+
Return type:
+

bool

+
+
Returns:
+

True if the task was found.

+
+
+
+ +
+
+__init__(name)[source]#
+

Initialize a new Scheduler instance.

+
+
Parameters:
+

name (str) – The name of the Scheduler. Used in logging, and namespacing.

+
+
+
+ +
+
+cancel(task_id)[source]#
+

Unschedule the task identified by task_id. Log a warning if the task doesn’t exist.

+
+
Parameters:
+

task_id (Hashable) – The task’s unique ID.

+
+
Return type:
+

None

+
+
+
+ +
+
+cancel_all()[source]#
+

Unschedule all known tasks.

+
+
Return type:
+

None

+
+
+
+ +
+
+schedule(task_id, coroutine)[source]#
+

Schedule the execution of a coroutine.

+

If a task with task_id already exists, close coroutine instead of scheduling it. This +prevents unawaited coroutine warnings. Don’t pass a coroutine that’ll be re-used elsewhere.

+
+
Parameters:
+
    +
  • task_id (Hashable) – A unique ID to create the task with.

  • +
  • coroutine (Coroutine) – The function to be called.

  • +
+
+
Return type:
+

None

+
+
+
+ +
+
+schedule_at(time, task_id, coroutine)[source]#
+

Schedule coroutine to be executed at the given time.

+

If time is timezone aware, then use that timezone to calculate now() when subtracting. +If time is naïve, then use UTC.

+

If time is in the past, schedule coroutine immediately.

+

If a task with task_id already exists, close coroutine instead of scheduling it. This +prevents unawaited coroutine warnings. Don’t pass a coroutine that’ll be re-used elsewhere.

+
+
Parameters:
+
    +
  • time (datetime) – The time to start the task.

  • +
  • task_id (Hashable) – A unique ID to create the task with.

  • +
  • coroutine (Coroutine) – The function to be called.

  • +
+
+
Return type:
+

None

+
+
+
+ +
+
+schedule_later(delay, task_id, coroutine)[source]#
+

Schedule coroutine to be executed after delay seconds.

+

If a task with task_id already exists, close coroutine instead of scheduling it. This +prevents unawaited coroutine warnings. Don’t pass a coroutine that’ll be re-used elsewhere.

+
+
Parameters:
+
    +
  • delay (Union[int, float]) – How long to wait before starting the task.

  • +
  • task_id (Hashable) – A unique ID to create the task with.

  • +
  • coroutine (Coroutine) – The function to be called.

  • +
+
+
Return type:
+

None

+
+
+
+ +
+ +
+
+create_task(coro, *, suppressed_exceptions=(), event_loop=None, **kwargs)[source]#
+

Wrapper for creating an asyncio.Task which logs exceptions raised in the task.

+

If the event_loop kwarg is provided, the task is created from that event loop, +otherwise the running loop is used.

+
+
Parameters:
+
+
+
Returns:
+

The wrapped task.

+
+
Return type:
+

asyncio.Task

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + + + \ No newline at end of file -- cgit v1.2.3