class Tourmaline::JsonPersistence
Overview
Persists users and chats in a json file. This isn't the most efficient, but it is easy to set up for testing.
Defined in:
tourmaline/persistence/json_persistence.crConstructors
Instance Method Summary
-
#cleanup
Gets called upon exit.
- #filename : String
- #filename=(filename : String)
-
#init
Gets called when the bot is initialized.
Instance methods inherited from class Tourmaline::HashPersistence
chat_exists?(chat_id : Int) : Boolchat_exists?(username : String) : Bool chat_exists?, cleanup cleanup, filename : String filename, 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, persisted_chat_ids : Hash(String, Int64) persisted_chat_ids, persisted_chats : Hash(Int64, Tourmaline::Chat) persisted_chats, persisted_user_ids : Hash(String, Int64) persisted_user_ids, persisted_users : Hash(Int64, Tourmaline::User) persisted_users, 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::HashPersistence
new(filename = nil)
new
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
Constructor Detail
Instance Method Detail
def cleanup
#
Description copied from class Tourmaline::Persistence
Gets called upon exit. It can be used to perform any necessary cleanup.
def init
#
Description copied from class Tourmaline::Persistence
Gets called when the bot is initialized. This can be used for setup if you need access to the bot instance.