class Database::User

Included Modules

Defined in:

privateparlor/database.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(rs : DB::ResultSet) #

[View source]
def self.new(id : Int64, username : Nil | String = nil, realname : String = "", rank : Int32 = 0, joined : Time = Time.utc, left : Time | Nil = nil, last_active : Time = Time.utc, cooldown_until : Time | Nil = nil, blacklist_reason : Nil | String = nil, warnings : Int32 = 0, warn_expiry : Time | Nil = nil, karma : Int32 = 0, hide_karma : Bool | Nil = false, debug_enabled : Bool | Nil = false, tripcode : Nil | String = nil) #

Create an instance of User


[View source]

Class Method Detail

def self.from_rs(rs : DB::ResultSet) #

[View source]

Instance Method Detail

def blacklist(reason : String | Nil) : Nil #

Set user's rank to blacklisted, force leave, and update blacklist reason.


[View source]
def blacklist_reason : String | Nil #

[View source]
def blacklisted? : Bool #

Returns true if rank is -10; user is blacklisted.

Returns false otherwise.


[View source]
def can_chat?(limit : Time::Span) : Bool #

Returns true if user is joined, not in cooldown, not blacklisted, and not limited; user can chat

Returns false otherwise.


[View source]
def can_chat? : Bool #

Returns true if user is joined, not in cooldown, and not blacklisted; user can chat

Returns false otherwise.


[View source]
def can_use_command? : Bool #

Returns true if user is joined and not blacklisted; user can use commands

Returns false otherwise.


[View source]
def cooldown(cooldown_time : Int32) : Time::Span #

[View source]
def cooldown_and_warn(cooldown_time_begin : Array(Int32), linear_m : Int32, linear_b : Int32, warn_expire_hours : Int32, penalty : Int32) : Time::Span #

Sets user's cooldown and increments total warnings


[View source]
def cooldown_and_warn(cooldown_time : Int32, warn_expire_hours : Int32, penalty : Int32) : Time::Span #

[View source]
def cooldown_until : Time | Nil #

[View source]
def debug_enabled : Bool | Nil #

[View source]
def decrement_karma(amount : Int32 = 1) : Nil #

Decrement the user's karma by a given amount (1 by default)


[View source]
def get_formatted_name : String #

Returns a string containing the username with an "@" appended to it if the user has a username.

Otherwise, the user's realname is returned.


[View source]
def get_obfuscated_id : String #

Get the user's obfuscated ID


[View source]
def get_obfuscated_karma : Int32 #

Get the user's obfuscated karma


[View source]
def hide_karma : Bool | Nil #

[View source]
def id : Int64 #

[View source]
def increment_karma(amount : Int32 = 1) : Nil #

Increment the user's karma by a given amount (1 by default)


[View source]
def joined : Time #

[View source]
def karma : Int32 #

[View source]
def last_active : Time #

[View source]
def left : Time | Nil #

[View source]
def left? : Bool #

Returns true if left is not nil; user has left the chat.

Returns false otherwise.


[View source]
def rank : Int32 #

[View source]
def realname : String #

[View source]
def rejoin : Nil #

Set left to nil, meaning that User has joined the chat.


[View source]
def remove_cooldown(override : Bool = false) : Bool #

Removes a cooldown from a user if it has expired.

Returns true if the cooldown can be expired, false otherwise


[View source]
def remove_warning(amount : Int32, warn_expire_hours : Int32) : Nil #

Removes one or multiple warnings from a user and resets the #warn_expiry


[View source]
def set_active : Nil #

Set last_active to the current time


[View source]
def set_left : Nil #

Set left to the current time; user has left the chat.


[View source]
def set_rank(rank_value : Int32) : Nil #

Set rank to the given Ranks value.


[View source]
def set_tripcode(tripcode : String) : Nil #

[View source]
def to_array #

Returns an array with all the values in User. Used for Database query arguments.


[View source]
def toggle_debug : Nil #

Set debug_enabled to its opposite value.


[View source]
def toggle_karma : Nil #

Set hide_karma to its opposite value.


[View source]
def tripcode : String | Nil #

[View source]
def update_names(username : String | Nil, fullname : String) : Nil #

Updates username and real name


[View source]
def username : String | Nil #

[View source]
def warn_expiry : Time | Nil #

[View source]
def warnings : Int32 #

[View source]