class Tourmaline::NilPersistence
- Tourmaline::NilPersistence
- Tourmaline::Persistence
- Reference
- Object
Overview
The default persistence, which is no persistence. This is basically just a placeholder class that does absolutely nothing, but still allows persistence methods to be accessed.
Defined in:
tourmaline/persistence/nil_persistence.crInstance Method Summary
-
#chat_exists?(chat_id : Int) : Bool
Returns true if the chat with the provided
chat_id
exists. -
#chat_exists?(username : String) : Bool
Returns true if the chat with the provided
username
exists. -
#cleanup
Gets called upon exit.
-
#get_chat(chat_id : Int) : Chat | Nil
Fetches a chat by
chat_id
. -
#get_chat(username : String) : Chat | Nil
Fetches a chat by
username
. -
#get_user(user_id : Int) : User | Nil
Fetches a user by
user_id
. -
#get_user(username : String) : User | Nil
Fetches a user by
username
. -
#handle_update(update : Update)
Takes an
Update
object, pulls out all uniqueChat
s andUser
s, and uses#update_user
and#update_chat
on each of them respectively. -
#init
Gets called when the bot is initialized.
-
#update_chat(chat : Chat) : Chat
Create or update the provided
Chat
. -
#update_user(user : User) : User
Create or update the provided
User
. -
#user_exists?(user_id : Int) : Bool
Returns true if the user with the provided
user_id
exists. -
#user_exists?(username : String) : Bool
Returns true if the user with the provided
username
exists.
Instance methods inherited from class Tourmaline::Persistence
chat_exists?(chat_id : Int) : Boolchat_exists?(username : String) : Bool chat_exists?, cleanup cleanup, get_chat(chat_id : Int) : Chat | Nil
get_chat(username : String) : Chat | Nil get_chat, get_user(user_id : Int) : User | Nil
get_user(username : String) : User | Nil get_user, handle_update(update : Update) handle_update, init init, update_chat(chat : Chat) : Chat update_chat, update_user(user : User) : User update_user, user_exists?(user_id : Int) : Bool
user_exists?(username : String) : Bool user_exists?
Constructor methods inherited from class Tourmaline::Persistence
new
new
Instance Method Detail
Returns true if the chat with the provided chat_id
exists.
Returns true if the chat with the provided username
exists.
Gets called upon exit. It can be used to perform any necessary cleanup.
Fetches a chat by chat_id
. Returns nil
if the chat is not found.
Fetches a chat by username
. Returns nil
if the chat is not found.
Fetches a user by user_id
. Returns nil
if the user is not found.
Fetches a user by username
. Returns nil
if the user is not found.
Takes an Update
object, pulls out all unique Chat
s and User
s,
and uses #update_user
and #update_chat
on each of them respectively.
Gets called when the bot is initialized. This can be used for setup if you need access to the bot instance.
Create or update the provided Chat
.
Create or update the provided User
.
Returns true if the user with the provided user_id
exists.
Returns true if the user with the provided username
exists.