class PrivateParlorXT::SQLiteDatabase
- PrivateParlorXT::SQLiteDatabase
- PrivateParlorXT::Database
- Reference
- Object
Overview
An implementation of Database
that uses a SQLite database for storing information about SQLiteUser
objects
Defined in:
private-parlor-xt/database/SQLite/sqlite_database.crConstructors
-
.new(connection : DB::Database)
Creates an instance of
SQLiteDatabase
and ensures that the proper tables exist
Instance Method Summary
-
#active_users(exclude : UserID) : Array(UserID)
Queries the database for the most active users, ordered by highest ranking users first, then most active users.
-
#active_users : Array(UserID)
Queries the database for the most active users, ordered by highest ranking users first, then most active users.
-
#add_user(id : UserID, username : String | Nil, realname : String, rank : Int32) : User | Nil
Adds a user to the database
-
#blacklisted_users(time_limit : Time::Span) : Array(User)
Get an array of recently blacklisted users
-
#blacklisted_users : Array(User)
Get an array of blacklisted users
-
#close
Close connection to the
Database
-
#ensure_schema : Nil
Ensures that the SQLite database has both a 'system_config' and a 'users' table
-
#expire_warnings(warn_lifespan : Time::Span) : Nil
Queries the database for users with warnings and removes a warning
-
#get_user(id : UserID | Nil) : User | Nil
Get user by
UserID
-
#get_user_by_name(username : String) : User | Nil
Get user by username
-
#get_user_by_oid(oid : String) : User | Nil
Get user by a four-digit obfuscated ID
-
#inactive_users(time_limit : Time::Span) : Array(User)
Get users that have not been active within a given time limit
-
#invalid_rank_users(valid_ranks : Array(Int32)) : Array(User)
Get an array of users whose ranks are currently invalid
-
#motd : String | Nil
Gets the MOTD/rules, if they exist
-
#no_users? : Bool | Nil
Returns true if there are no users in the database False otherwise
-
#set_motd(text : String) : Nil
Sets the MOTD/rules to the given string
-
#update_user(user : User) : Nil
Updates a user with new data
-
#user_counts : NamedTuple(total: Int32, left: Int32, blacklisted: Int32)
Get the total count of users, users that have stopped the bot, and users that are blacklisted
-
#warned_users : Array(User)
Get an array of warned users
Instance methods inherited from class PrivateParlorXT::Database
active_users(exclude : UserID) : Array(UserID)active_users : Array(UserID) active_users, add_user(id : UserID, username : String | Nil, realname : String, rank : Int32) : User | Nil add_user, blacklisted_users(time_limit : Time::Span) : Array(User)
blacklisted_users : Array(User) blacklisted_users, close close, expire_warnings(warn_lifespan : Time::Span) : Nil expire_warnings, get_user(id : UserID | Nil) : User | Nil get_user, get_user_by_arg(arg : String) : User | Nil get_user_by_arg, get_user_by_name(username : String) : User | Nil get_user_by_name, get_user_by_oid(oid : String) : User | Nil get_user_by_oid, inactive_users(time_limit : Time::Span) : Array(User) | Nil inactive_users, invalid_rank_users(valid_ranks : Array(Int32)) : Array(User) | Nil invalid_rank_users, motd : String | Nil motd, no_users? : Bool | Nil no_users?, set_motd(text : String) : Nil set_motd, update_user(user : User) : Nil update_user, user_counts : NamedTuple(total: Int32, left: Int32, blacklisted: Int32) user_counts, warned_users : Array(User) | Nil warned_users
Constructor methods inherited from class PrivateParlorXT::Database
new
new
Constructor Detail
Creates an instance of SQLiteDatabase
and ensures that the proper tables exist
Instance Method Detail
Queries the database for the most active users, ordered by highest ranking users first, then most active users.
Use this to exclude a user from the result (i.e., when a user does not have debug mode enabled)
Queries the database for the most active users, ordered by highest ranking users first, then most active users.
Adds a user to the database
Get an array of recently blacklisted users
Ensures that the SQLite database has both a 'system_config' and a 'users' table
Queries the database for users with warnings and removes a warning
If the user still has warnings, the next time a warning is removed should be the current time plus the value of warn_lifespan
This should be invoked as a recurring task
Get user by a four-digit obfuscated ID
Get users that have not been active within a given time limit
Get an array of users whose ranks are currently invalid
Get the total count of users, users that have stopped the bot, and users that are blacklisted