class Database::User
- Database::User
- Reference
- Object
Included Modules
- DB::Mappable
- DB::Serializable
Defined in:
privateparlor/database.crConstructors
- .new(rs : DB::ResultSet)
-
.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
Class Method Summary
Instance Method Summary
-
#blacklist(reason : String | Nil) : Nil
Set user's rank to blacklisted, force leave, and update blacklist reason.
- #blacklist_reason : String | Nil
-
#blacklisted? : Bool
Returns
true
if rank is -10; user is blacklisted. -
#can_chat?(limit : Time::Span) : Bool
Returns
true
if user is joined, not in cooldown, not blacklisted, and not limited; user can chat -
#can_chat? : Bool
Returns
true
if user is joined, not in cooldown, and not blacklisted; user can chat -
#can_use_command? : Bool
Returns
true
if user is joined and not blacklisted; user can use commands - #cooldown(cooldown_time : Int32) : Time::Span
-
#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
- #cooldown_and_warn(cooldown_time : Int32, warn_expire_hours : Int32, penalty : Int32) : Time::Span
- #cooldown_until : Time | Nil
- #debug_enabled : Bool | Nil
-
#decrement_karma(amount : Int32 = 1) : Nil
Decrement the user's karma by a given amount (1 by default)
-
#get_formatted_name : String
Returns a string containing the username with an "@" appended to it if the user has a username.
-
#get_obfuscated_id : String
Get the user's obfuscated ID
-
#get_obfuscated_karma : Int32
Get the user's obfuscated karma
- #hide_karma : Bool | Nil
- #id : Int64
-
#increment_karma(amount : Int32 = 1) : Nil
Increment the user's karma by a given amount (1 by default)
- #joined : Time
- #karma : Int32
- #last_active : Time
- #left : Time | Nil
-
#left? : Bool
Returns
true
if left is not nil; user has left the chat. - #rank : Int32
- #realname : String
-
#rejoin : Nil
Set left to nil, meaning that User has joined the chat.
-
#remove_cooldown(override : Bool = false) : Bool
Removes a cooldown from a user if it has expired.
-
#remove_warning(amount : Int32, warn_expire_hours : Int32) : Nil
Removes one or multiple warnings from a user and resets the
#warn_expiry
-
#set_active : Nil
Set last_active to the current time
-
#set_left : Nil
Set left to the current time; user has left the chat.
-
#set_rank(rank_value : Int32) : Nil
Set rank to the given
Ranks
value. - #set_tripcode(tripcode : String) : Nil
-
#to_array
Returns an array with all the values in
User
. -
#toggle_debug : Nil
Set debug_enabled to its opposite value.
-
#toggle_karma : Nil
Set hide_karma to its opposite value.
- #tripcode : String | Nil
-
#update_names(username : String | Nil, fullname : String) : Nil
Updates username and real name
- #username : String | Nil
- #warn_expiry : Time | Nil
- #warnings : Int32
Constructor Detail
Create an instance of User
Class Method Detail
Instance Method Detail
Set user's rank to blacklisted, force leave, and update blacklist reason.
Returns true
if rank is -10; user is blacklisted.
Returns false
otherwise.
Returns true
if user is joined, not in cooldown, not blacklisted, and not limited; user can chat
Returns false otherwise.
Returns true
if user is joined, not in cooldown, and not blacklisted; user can chat
Returns false otherwise.
Returns true
if user is joined and not blacklisted; user can use commands
Returns false otherwise.
Sets user's cooldown and increments total warnings
Decrement the user's karma by a given amount (1 by default)
Returns a string containing the username with an "@" appended to it if the user has a username.
Otherwise, the user's realname is returned.
Increment the user's karma by a given amount (1 by default)
Returns true
if left is not nil; user has left the chat.
Returns false
otherwise.
Removes a cooldown from a user if it has expired.
Returns true if the cooldown can be expired, false otherwise
Removes one or multiple warnings from a user and resets the #warn_expiry