cyberjake package
Submodules
cyberjake.check_update module
Script to check for available updates.
- cyberjake.check_update.check_update(project_name: str, current_version: str) bool[source]
Check version against pypi.org information
Requires Requests Requires Packaging
- Parameters:
project_name – Name of project to check
current_version – Current version of project. Usually from __version__
- Returns:
Latest version is newer. Returns false if project can’t be found
- Return type:
bool
cyberjake.database module
Common for database tools
- cyberjake.database.build_database_url(protocol: str) str[source]
Builds a database url from environment variables
Environment variable used: DATABASE_USER, DATABASE_PASSWORD, DATABASE_HOST, DATABASE_PORT, DATABASE_DATABASE
- Raises:
NotImplementedError – Raised if using an unsupported protocol
- Parameters:
protocol (str) – The database protocol to use. Currently, mysql and postgres are supported
- Returns:
Database URL
- Return type:
str
cyberjake.discord_common module
Common code for discord bots
- cyberjake.discord_common.error_embed(ctx: Context | Interaction, message: str, title: str = 'Error:', **kwargs)[source]
Makes and send an error embed
Requires discord.py
Asynchronous Function
- Raises:
ModuleNotFoundError – Will raise a ModuleNotFoundError if discord.py module is not installed
- Parameters:
ctx (discord.ext.commands.Context) – Command context
message (str) – Message description
title (str) – Error message title
- cyberjake.discord_common.error_message(ctx: Context | Interaction, message: str, title: str = 'Error:', **kwargs) None[source]
Error Message Generate an error embed
Requires discord.py
Asynchronous Function
- Parameters:
ctx (discord.ext.commands.Context) – Discord Context
message – Message of the error
title – Title of error embed
kwargs – Keyword arguments to pass to Embed
- cyberjake.discord_common.list_message(ctx: Context | Interaction, message: list, title: str, **kwargs) List[Embed] | None[source]
List Message
Breaks up messages that contain a list and sends the parts of them. Shared function between multiple commands.
Requires discord.py
Asynchronous Function
I’m sorry for everyone dealing with this function. It is not clean and I have commented to the best that I can.
- Parameters:
ctx (discord.ext.commands.Context) – Context of command.
message (list) – list of items to send.
title (str) – Title of the message to send.
kwargs (dict) – keyword arguments
- Returns:
All embeds are sent
“:rtype: None
- cyberjake.discord_common.make_embed(ctx: discord.commands.Context | discord.Interaction, color: str | int | discord.Color = None, send: bool | str = True, as_reply: bool = False, **kwargs) discord.Embed | None[source]
Makes and defaults to sending a discord.Embed
Asynchronous Function
- Raises:
ModuleNotFoundError – Will raise a ModuleNotFoundError if discord.py module is not installed
- Parameters:
ctx (discord.ext.commands.Context | discord.Interaction) – Discord context or interaction
color ([str, int, discord.Color]) – Color of the embed
send (bool) – Send the message instead of returning
as_reply (bool) – Reply to the message instead of sending
kwargs – Keyword arguments to pass to embed
- Returns:
Filled out embed if send is False
cyberjake.file_utils module
utils for file handling
cyberjake.make_logger module
Common log maker
- cyberjake.make_logger.make_logger(name: str, log_level: str = 'INFO') Logger[source]
Creates a logger class that handles stream and file output
- Parameters:
name (str) – Name of logger
log_level (str) – Logging level. Valid strings are ‘DEBUG’, ‘INFO’, ‘WARNING’, ‘ERROR’, ‘CRITICAL’
- Returns:
Logger class that handled the logging.
- Return type:
logging.Logger
cyberjake.text_utils module
text_utils
Text utility functions
Module contents
Common code
- cyberjake.build_database_url(protocol: str) str[source]
Builds a database url from environment variables
Environment variable used: DATABASE_USER, DATABASE_PASSWORD, DATABASE_HOST, DATABASE_PORT, DATABASE_DATABASE
- Raises:
NotImplementedError – Raised if using an unsupported protocol
- Parameters:
protocol (str) – The database protocol to use. Currently, mysql and postgres are supported
- Returns:
Database URL
- Return type:
str
- cyberjake.check_update(project_name: str, current_version: str) bool[source]
Check version against pypi.org information
Requires Requests Requires Packaging
- Parameters:
project_name – Name of project to check
current_version – Current version of project. Usually from __version__
- Returns:
Latest version is newer. Returns false if project can’t be found
- Return type:
bool
- cyberjake.error_embed(ctx: Context | Interaction, message: str, title: str = 'Error:', **kwargs)[source]
Makes and send an error embed
Requires discord.py
Asynchronous Function
- Raises:
ModuleNotFoundError – Will raise a ModuleNotFoundError if discord.py module is not installed
- Parameters:
ctx (discord.ext.commands.Context) – Command context
message (str) – Message description
title (str) – Error message title
- cyberjake.list_message(ctx: Context | Interaction, message: list, title: str, **kwargs) List[Embed] | None[source]
List Message
Breaks up messages that contain a list and sends the parts of them. Shared function between multiple commands.
Requires discord.py
Asynchronous Function
I’m sorry for everyone dealing with this function. It is not clean and I have commented to the best that I can.
- Parameters:
ctx (discord.ext.commands.Context) – Context of command.
message (list) – list of items to send.
title (str) – Title of the message to send.
kwargs (dict) – keyword arguments
- Returns:
All embeds are sent
“:rtype: None
- cyberjake.make_embed(ctx: discord.commands.Context | discord.Interaction, color: str | int | discord.Color = None, send: bool | str = True, as_reply: bool = False, **kwargs) discord.Embed | None[source]
Makes and defaults to sending a discord.Embed
Asynchronous Function
- Raises:
ModuleNotFoundError – Will raise a ModuleNotFoundError if discord.py module is not installed
- Parameters:
ctx (discord.ext.commands.Context | discord.Interaction) – Discord context or interaction
color ([str, int, discord.Color]) – Color of the embed
send (bool) – Send the message instead of returning
as_reply (bool) – Reply to the message instead of sending
kwargs – Keyword arguments to pass to embed
- Returns:
Filled out embed if send is False
- cyberjake.make_logger(name: str, log_level: str = 'INFO') Logger[source]
Creates a logger class that handles stream and file output
- Parameters:
name (str) – Name of logger
log_level (str) – Logging level. Valid strings are ‘DEBUG’, ‘INFO’, ‘WARNING’, ‘ERROR’, ‘CRITICAL’
- Returns:
Logger class that handled the logging.
- Return type:
logging.Logger