Utils¶
Checks¶
This module provides basic checks to common procedures.
-
utils.checks.
confirm
(author)[source]¶ Parameters: author – The ctx.author attribute value. Returns: True if the author matches the context and properly responds, False otherwise.
-
utils.checks.
is_dm
(ctx)[source]¶ Check to see if the message received is a direct message.
Parameters: ctx – The invocation context. Returns: True if the context is a direct message, False otherwise.
-
utils.checks.
is_number
(author)[source]¶ Parameters: author – The ctx.author attribute value. Returns: True if the author matches the context and properly responds, False otherwise.
-
utils.checks.
is_registered
()[source]¶ Check to see if the user is registered in database.
Returns: True if the utils.fjclasses.DiscordUser
exists.Raises: utils.fjclasses.UserNotRegisteredError
if User is not found in database.
FJClasses¶
This module contains all classes and models used throughout the bot.
_Abstract¶
_Base¶
-
class
utils.fjclasses.
_Base
(id=None, name=None)[source]¶ A generic class with only id and name attribute.
-
fill_info
(row)[source]¶ Abstract function for applying object’s attribute values based on query result.
Parameters: row – The SQL result.
-
id
¶ The object’s unique identifier value.
Type: return
-
name
¶ The name of the object.
Type: return
-
_Database¶
-
class
utils.fjclasses.
_Database
[source]¶ A generic database handler.
-
connection
¶ The database connection.
Type: return
-
cursor
¶ The database cursor.
Type: return
-
db
¶ The database object (itself).
Type: return
-
_User¶
-
class
utils.fjclasses.
_User
[source]¶ A generic class used by different user types.
-
current_bets
()[source]¶ Return the list of currently placed bets.
Returns: Query result of currently placed bets. Error message if none.
-
fill_info
(row)[source]¶ Applies attributes based on query result.
Parameters: row – The query result.
-
fjbucks_check
(amount)[source]¶ Checks whether the FJBucks transaction is valid to make.
Parameters: amount – The amount of FJBucks for the transaction. Returns: Query result with success or failure message.
-
fjbucks_transaction
(amount, note)[source]¶ Calls stored procedure to create a FJBucks transaction.
Parameters: - amount – The amount of FJBucks for the transaction.
- note – A memo for the transaction.
Returns: Query result with success or failure message.
-
is_registered
()[source]¶ Checks if the user is registered.
Returns: True if id and username values exist, False otherwise.
-
mention
¶ Abstract function to notify the user inside the chat.
-
place_bet
(match_id, team, bet)[source]¶ Places a bet for match.
Parameters: - match_id – The Match id to bet for.
- team – The Match team id to bet for.
- bet – The amount betting.
Returns: Query result with success or failure message.
-
rate_match
(match_id, rating)[source]¶ Places a rating for a match.
Parameters: - match_id – The Match id to rate for.
- rating – The rating for the match.
Returns: Query result with success or failure message.
-
request_login_link
()[source]¶ Creates hyperlink to auto-login user to the website.
This creates a randomized token that allows the user to bypass initial login screen.
Important
Do not post this link in a public chat. It must be DMed to the user requesting it only. Once the hyperlink can only be used once and within a short time frame.
Returns: The hyperlink to auto-login a user to the website.
-
request_reset_password_link
()[source]¶ Creates hyperlink to reset the user’s password.
Once called a temporary password is set for the user to bypass their original password.This is required for users that have no yet set up a password for their account; users that registered through the bot and not the website.
Important
Do not post this link in a public chat. It must be DMed to the user requesting it only. Once the hyperlink can only be used once and within a short time frame.
Returns: The hyperlink to reset the user’s password for the website.
-
stats
(season)[source]¶ Return user’s stats for the Matches season.
Parameters: season – The Match season to fetch stats for. Returns: The user stats for the Matches season.
-
username
¶ The user’s username.
Type: return
-
ChatangoUser¶
-
class
utils.fjclasses.
ChatangoUser
(author)[source]¶ This class is used to refer to individual Chatango authors.
-
chatango
¶ The author. (itself)
Type: return
-
fetch_info
()[source]¶ Fetches attribute values from database using current Chatango author unique identifier (name).
Note
If no results are found with id, no attributes are set.
-
mention
¶ The author’s mention.
Type: return
-
name
¶ The author’s name.
Type: return
-
DbHelper¶
-
class
utils.fjclasses.
DbHelper
[source]¶ This class handles the most common and generic queries.
-
add_chatroom_command
(command, response)[source]¶ TODO
Parameters: - command – The chatroom command to insert.
- response – The response for the chatroom command.
-
chatroom_command
(command)[source]¶ Fetches response to a quick chatroom command.
Parameters: command – The command to fetch the response for. Returns: The query result if found, False otherwise.
-
chatroom_command_list
()[source]¶ Fetches the complete list of available chatroom commands.
Returns: The query result of chatroom commands ordered by alpha.
-
chatroom_scheduler_list
()[source]¶ Fetches list of weekly alert scheduler.
Returns: The query result for the weekly schedule.
-
future_events
(ppv_check=0)[source]¶ Fetches list of upcoming PPV events.
Parameters: ppv_check – The PPV flag check. Default is 0. Returns: The query result of upcoming events.
-
guild_info
(guild_id)[source]¶ Fetches Discord guild information by id.
Parameters: guild_id – The guild id. Returns: The command prefix for the guild, False otherwise.
-
leaderboard
(season)[source]¶ Fetches the leaderboard for the season.
Parameters: season – The season id. Returns: Query result of User stats ordered by total points for the season.
-
search_match_by_current
()[source]¶ Fetches info for the current Match.
Returns: A list of :class:’utils.fjclasses._Base’.
-
search_match_by_id
(id)[source]¶ Fetches Match info by id.
Parameters: id – The Match id. Returns: A list of :class:’utils.fjclasses._Base’.
-
search_match_by_open_bets
()[source]¶ Fetches info for Matches that are available to bet on.
Returns: A list of :class:’utils.fjclasses._Base’.
-
search_match_by_open_bets_and_superstar_name
(name)[source]¶ Fetches info for Matches that are available to bet on and contain the Superstar.
Parameters: name – The Superstar name. Returns: A list of :class:’utils.fjclasses._Base’.
-
search_match_by_recent_completed
()[source]¶ Fetches info for the most recently completed Match.
Returns: A list of :class:’utils.fjclasses._Base’.
-
search_superstar_by_name
(name)[source]¶ Fetches Superstar info by name.
Parameters: name – The Superstar’s name to query for. Returns: A list of :class:’utils.fjclasses._Base’.
-
search_user_by_name
(name)[source]¶ Fetches User info by name.
Parameters: name – The User’s name to query for. Returns: A list of :class:’utils.fjclasses._Base’.
-
superstar_birthday_upcoming
()[source]¶ Fetches Superstar info who’s birthday is coming up.
Returns: The query result of Superstars.
-
DiscordUser¶
-
class
utils.fjclasses.
DiscordUser
(author)[source]¶ This class is used to refer to individual Discord authors.
-
discord
¶ The author object. (itself)
Type: return
-
fetch_info
()[source]¶ Fetches attribute values from database using current Discord author unique identifier (id).
Note
If no results are found with id, no attributes are set.
-
fjbucks_wallet_embed
()[source]¶ Creates rich content of the User’s FJBucks wallet.
Returns: Rich content.
-
mention
¶ The author’s mention value.
Type: return
-
name
¶ The author’s name value.
Type: return
-
Match¶
-
class
utils.fjclasses.
Match
(id=None)[source]¶ The class is used to refer to individual Matches.
-
contains_contestant
(name)[source]¶ Checks if Superstar is a Match contestant.
Parameters: name – The Superstar name. Returns: True if the Superstar is a contestant, False otherwise.
-
contestants_by_team
(team_id)[source]¶ Returns the list of Superstars in the Match based on the team id.
Parameters: team_id – The team id. Returns: The list Superstars in the team, False otherwise.
-
fetch_info
()[source]¶ Fetches attribute values from database using current Match unique identifier (id).
Note
If no results are found with id, no attributes are set.
-
fill_info
(row)[source]¶ Applies attributes based on query result.
Parameters: row – The query result.
-
info_text_short
()[source]¶ Formatted text of a Match’s info. (short version)
Returns: Formatted text.
-
Superstar¶
-
class
utils.fjclasses.
Superstar
(id=None)[source]¶ This class is used to refer to individual Superstars.
-
fetch_info
()[source]¶ Fetches attribute values from database using current Chatango author unique identifier (id).
Note
If no results are found with id, no attributes are set.
-
QuickEmbed¶
This module provides a quick way to personalize messages back to the user.
Instead of flat text messages or going through all the steps to setup and personalize rich content, this module is used.
-
utils.quickembed.
error
(desc, user=None)[source]¶ Styles the rich content for a failed response. Colored red.
Parameters: - desc – The title of the rich content.
- user – The
utils.fjclasses.DiscordUser
responding to.
Returns: The personalized rich content.
-
utils.quickembed.
filler
(embed, desc, user)[source]¶ Creates the rich content and fills in all user info.
Parameters: - embed – The base rich content.
- desc – The title of the rich content.
- user – The
utils.fjclasses.DiscordUser
responding to.
Returns: The personalized rich content.
-
utils.quickembed.
general
(desc, user=None)[source]¶ Styles the rich content for a generic response. Colored blue.
Parameters: - desc – The title of the rich content.
- user – The
utils.fjclasses.DiscordUser
responding to.
Returns: The personalized rich content.
-
utils.quickembed.
info
(desc, user=None)[source]¶ Styles the rich content for a informative response. Colored white.
Parameters: - desc – The title of the rich content.
- user – The
utils.fjclasses.DiscordUser
responding to.
Returns: The personalized rich content.
-
utils.quickembed.
question
(desc, user=None)[source]¶ Styles the rich content for a question response. Colored yellow.
Parameters: - desc – The title of the rich content.
- user – The
utils.fjclasses.DiscordUser
responding to.
Returns: The personalized rich content.
-
utils.quickembed.
success
(desc, user=None)[source]¶ Styles the rich content for a successful response. Colored green.
Parameters: - desc – The title of the rich content.
- user – The
utils.fjclasses.DiscordUser
responding to.
Returns: The personalized rich content.