abstract class PrivateParlorXT::Database

Overview

A base class for Database implementations, used for storing and retrieving data about users

Direct Known Subclasses

Defined in:

private-parlor-xt/database/database.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

Creates an instance of Database


[View source]

Instance Method Detail

abstract def 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)


[View source]
abstract def active_users : Array(UserID) #

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


[View source]
abstract def add_user(id : UserID, username : String | Nil, realname : String, rank : Int32) : User | Nil #

Adds a user to the database


[View source]
abstract def blacklisted_users(time_limit : Time::Span) : Array(User) #

Get an array of recently blacklisted users


[View source]
abstract def blacklisted_users : Array(User) #

Get an array of blacklisted users


[View source]
def close #

Close connection to the Database


[View source]
abstract def 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


[View source]
abstract def get_user(id : UserID | Nil) : User | Nil #

Get user by UserID


[View source]
def get_user_by_arg(arg : String) : User | Nil #

Get user by a given arg, calling the appropriate function


[View source]
abstract def get_user_by_name(username : String) : User | Nil #

Get user by username


[View source]
abstract def get_user_by_oid(oid : String) : User | Nil #

Get user by a four-digit obfuscated ID


[View source]
abstract def inactive_users(time_limit : Time::Span) : Array(User) | Nil #

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


[View source]
abstract def invalid_rank_users(valid_ranks : Array(Int32)) : Array(User) | Nil #

Get an array of users whose ranks are currently invalid


[View source]
abstract def motd : String | Nil #

Gets the MOTD/rules, if they exist


[View source]
abstract def no_users? : Bool | Nil #

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


[View source]
abstract def set_motd(text : String) : Nil #

Sets the MOTD/rules to the given string


[View source]
abstract def update_user(user : User) : Nil #

Updates a user with new data


[View source]
abstract def 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


[View source]
abstract def warned_users : Array(User) | Nil #

Get an array of warned users


[View source]