class Database
- Database
- Reference
- Object
Defined in:
privateparlor/database.crConstructors
-
.new(database : DB::Database)
Create an instance of Database and create the appropriate schema in the SQLite database.
Instance Method Summary
-
#add_user(id, username, realname, rank = 0) : User | Nil
Inserts a user with the given id, username, and realname into the database.
- #db : DB::Database
-
#ensure_schema : Nil
Ensures that the DB schema is usable by the program.
-
#expire_warnings(warn_expire_hours : Int32) : Nil
Queries the database for warned users and removes warnings they have expired.
-
#get_blacklisted_users : Array(User) | Nil
Queries the database for blacklisted users who have been banned within the past 48 hours.
- #get_inactive_users(limit : Int32) : Array(User) | Nil
- #get_invalid_rank_users(values : Array(Int32)) : Array(User) | Nil
-
#get_motd : String | Nil
Retrieves the motd/rules from the database.
-
#get_prioritized_users(user : User | Nil = nil) : Array(Int64)
Queries the database for all user ids, ordered by highest ranking users first then most active users.
-
#get_user(id) : User | Nil
Queries the database for a user record with the given id.
- #get_user_by_arg(arg : String) : User | Nil
-
#get_user_by_name(username) : User | Nil
Queries the database for a user with a given username.
- #get_user_by_oid(oid : String) : User | Nil
- #get_user_counts : NamedTuple
-
#get_warned_users : Array(User) | Nil
Queries the database for all warned users that are in the chat.
-
#modify_user(user : User) : Nil
Updates a user record in the database with the current state of user.
-
#no_users? : Bool
Queries the database for any rows in the user table
-
#set_motd(text : String) : Nil
Sets the motd/rules to the given string.
Constructor Detail
Create an instance of Database and create the appropriate schema in the SQLite database.
Instance Method Detail
Inserts a user with the given id, username, and realname into the database.
Returns the new User
.
Ensures that the DB schema is usable by the program.
This is the same schema used in secretlounge-ng SQLite databases.
Queries the database for warned users and removes warnings they have expired.
Queries the database for blacklisted users who have been banned within the past 48 hours.
Returns an array of User
or Nil
if no users were found.
Retrieves the motd/rules from the database.
Returns the motd as a string, or returns nil if the motd could not be retrieved.
Queries the database for all user ids, ordered by highest ranking users first then most active users.
Queries the database for a user record with the given id.
Returns a User
object.
Queries the database for a user with a given username.
Returns a User
object or Nil if no user was found.
Queries the database for all warned users that are in the chat.
Returns an array of User
or Nil
if no users were found.
Updates a user record in the database with the current state of user.
Queries the database for any rows in the user table
Returns true if can't move to next row (table is empty). False otherwise.