class

PrivateParlorXT::SQLiteDatabase

Inherits PrivateParlorXT::Database < Reference < Object

An implementation of Database that uses a SQLite database for storing information about SQLiteUser objects

Constructors

new(connection : DB::Database)

Creates an instance of SQLiteDatabase and ensures that the proper tables exist

Source

Instance methods

active_users(exclude : UserID) : Array(UserID)

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)

Source
active_users

Queries the database for the most active users, ordered by highest ranking users first, then most active users.

Source
add_user(id : UserID, username : String | Nil, realname : String, rank : Int32) : User | Nil

Adds a user to the database

Source
blacklisted_users(time_limit : Time::Span) : Array(User)

Get an array of recently blacklisted users

Source
blacklisted_users

Get an array of blacklisted users

Source
close

Close connection to the Database

Source
ensure_schema

Ensures that the SQLite database has both a 'system_config' and a 'users' table

Source
expire_warnings(warn_lifespan : Time::Span) : Nil

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

Source
get_user(id : UserID | Nil) : User | Nil

Get user by UserID

Source
get_user_by_name(username : String) : User | Nil

Get user by username

Source
get_user_by_oid(oid : String) : User | Nil

Get user by a four-digit obfuscated ID

Source
inactive_users(time_limit : Time::Span) : Array(User)

Get users that have not been active within a given time limit

Source
invalid_rank_users(valid_ranks : Array(Int32)) : Array(User)

Get an array of users whose ranks are currently invalid

Source
motd

Gets the MOTD/rules, if they exist

Source
no_users?

Returns true if there are no users in the database False otherwise

Source
set_motd(text : String) : Nil

Sets the MOTD/rules to the given string

Source
update_user(user : User) : Nil

Updates a user with new data

Source
user_counts

Get the total count of users, users that have stopped the bot, and users that are blacklisted

Source
warned_users

Get an array of warned users

Source