Bots¶
The following section documents everything related to bot system.
BaseBot¶
- class stoat.BaseBot(*, state, id)[source]¶
Represents a base bot on Stoat.
This inherits from
Base.- await delete(*, http_overrides=None)[source]¶
This function is a coroutine.
Deletes the bot.
Fires
UserUpdateEventfor all users who are subscribed <server_subscriptions>_ to bot user.Note
This can only be used by non-bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe bot was not found, or the current user does not own bot.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await edit(*, http_overrides=None, name=UNDEFINED, public=UNDEFINED, analytics=UNDEFINED, interactions_url=UNDEFINED, oauth2=UNDEFINED, reset_oauth2_client_secret=False, reset_token=False)[source]¶
This function is a coroutine.
Edits the bot.
Fires
UserUpdateEventfor all users who are subscribed to bot user.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (UndefinedOr[
str]) – The new bot name. Must be between 2 and 32 characters and not contain whitespace characters.public (UndefinedOr[
bool]) – Whether the bot should be public (could be invited by anyone).analytics (UndefinedOr[
bool]) – Whether to allow Stoat collect analytics about the bot.interactions_url (UndefinedOr[Optional[
str]]) – The new bot interactions URL. For now, this parameter is reserved and does not do anything.oauth2 (UndefinedOr[Optional[
BotOAuth2Edit]]) – The new bot’s OAuth2 settings.reset_oauth2_client_secret (
bool) – Whether to reset bot’s OAuth2 client secret. The new client secret can be accessed viaBotOAuth2.secret.reset_token (
bool) – Whether to reset bot token. The new token can be accessed viabot.token.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe bot’s name exceeded length or contained whitespace.
InvalidUsernameThe bot’s name had forbidden characters/substrings.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe bot was not found, or the current user does not own bot.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The updated bot.
- Return type:
Bot¶
- class stoat.Bot(token, *, state, id, owner_id, public, analytics, discoverable, interactions_url, terms_of_service_url, privacy_policy_url, oauth2, raw_flags, user)[source]¶
Represents a bot on Stoat.
This inherits from
BaseBot.- interactions_url¶
The URL to send interactions to.
Note
This attribute is reserved.
- Type:
Optional[
str]
- await delete(*, http_overrides=None)[source]¶
This function is a coroutine.
Deletes the bot.
Fires
UserUpdateEventfor all users who are subscribed <server_subscriptions>_ to bot user.Note
This can only be used by non-bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe bot was not found, or the current user does not own bot.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await edit(*, http_overrides=None, name=UNDEFINED, public=UNDEFINED, analytics=UNDEFINED, interactions_url=UNDEFINED, oauth2=UNDEFINED, reset_oauth2_client_secret=False, reset_token=False)[source]¶
This function is a coroutine.
Edits the bot.
Fires
UserUpdateEventfor all users who are subscribed to bot user.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (UndefinedOr[
str]) – The new bot name. Must be between 2 and 32 characters and not contain whitespace characters.public (UndefinedOr[
bool]) – Whether the bot should be public (could be invited by anyone).analytics (UndefinedOr[
bool]) – Whether to allow Stoat collect analytics about the bot.interactions_url (UndefinedOr[Optional[
str]]) – The new bot interactions URL. For now, this parameter is reserved and does not do anything.oauth2 (UndefinedOr[Optional[
BotOAuth2Edit]]) – The new bot’s OAuth2 settings.reset_oauth2_client_secret (
bool) – Whether to reset bot’s OAuth2 client secret. The new client secret can be accessed viaBotOAuth2.secret.reset_token (
bool) – Whether to reset bot token. The new token can be accessed viabot.token.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe bot’s name exceeded length or contained whitespace.
InvalidUsernameThe bot’s name had forbidden characters/substrings.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe bot was not found, or the current user does not own bot.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The updated bot.
- Return type:
PublicBot¶
- class stoat.PublicBot(*, state, id, name, internal_avatar_id, description)[source]¶
Represents public bot on Stoat.
This inherits from
BaseBot.- await delete(*, http_overrides=None)[source]¶
This function is a coroutine.
Deletes the bot.
Fires
UserUpdateEventfor all users who are subscribed <server_subscriptions>_ to bot user.Note
This can only be used by non-bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe bot was not found, or the current user does not own bot.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await edit(*, http_overrides=None, name=UNDEFINED, public=UNDEFINED, analytics=UNDEFINED, interactions_url=UNDEFINED, oauth2=UNDEFINED, reset_oauth2_client_secret=False, reset_token=False)[source]¶
This function is a coroutine.
Edits the bot.
Fires
UserUpdateEventfor all users who are subscribed to bot user.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (UndefinedOr[
str]) – The new bot name. Must be between 2 and 32 characters and not contain whitespace characters.public (UndefinedOr[
bool]) – Whether the bot should be public (could be invited by anyone).analytics (UndefinedOr[
bool]) – Whether to allow Stoat collect analytics about the bot.interactions_url (UndefinedOr[Optional[
str]]) – The new bot interactions URL. For now, this parameter is reserved and does not do anything.oauth2 (UndefinedOr[Optional[
BotOAuth2Edit]]) – The new bot’s OAuth2 settings.reset_oauth2_client_secret (
bool) – Whether to reset bot’s OAuth2 client secret. The new client secret can be accessed viaBotOAuth2.secret.reset_token (
bool) – Whether to reset bot token. The new token can be accessed viabot.token.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe bot’s name exceeded length or contained whitespace.
InvalidUsernameThe bot’s name had forbidden characters/substrings.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe bot was not found, or the current user does not own bot.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The updated bot.
- Return type:
BotOAuth2¶
- class stoat.BotOAuth2(*, public, secret, redirect_uris, allowed_scopes)[source]¶
Represents how the bot does use OAuth2.
Added in version 1.2.
- allowed_scopes¶
A mapping of OAuth2 scopes to reasoning why would it be requested.
- Type:
Dict[
str,OAuth2ScopeReasoning]
BotOAuth2Edit¶
- class stoat.BotOAuth2Edit(*, public=UNDEFINED, redirect_uris=UNDEFINED, allowed_scopes=UNDEFINED)[source]¶
Represents new bot’s OAuth2 settings.
Added in version 1.2.
- redirect_uris¶
The whitelisted URIs for redirecting to during OAuth2 authorization. Must be between 1 and 10 items.
- Type:
UndefinedOr[List[
str]]
- allowed_scopes¶
A mapping of OAuth2 scopes to reasoning why would it be requested.
- Type:
UndefinedOr[Dict[Union[
OAuth2Scope,str],OAuth2ScopeReasoning]]