class

Tourmaline::HashPersistence

Inherits Tourmaline::Persistence < Reference < Object

Stores all persisted data in memory using a collection of hash tables.

Constructors

new(filename = nil)
Source

Instance methods

chat_exists?(chat_id : Int) : Bool

Returns true if the chat with the provided chat_id exists.

Source
chat_exists?(username : String) : Bool

Returns true if the chat with the provided username exists.

Source
cleanup

Gets called upon exit. It can be used to perform any necessary cleanup.

Source
filename
Source
get_chat(chat_id : Int) : Chat | Nil

Fetches a chat by chat_id. Returns nil if the chat is not found.

Source
get_chat(username : String) : Chat | Nil

Fetches a chat by username. Returns nil if the chat is not found.

Source
get_user(user_id : Int) : User | Nil

Fetches a user by user_id. Returns nil if the user is not found.

Source
get_user(username : String) : User | Nil

Fetches a user by username. Returns nil if the user is not found.

Source
handle_update(update : Update)

Takes an Update object, pulls out all unique Chats and Users, and uses update_user and update_chat on each of them respectively.

Source
init

Gets called when the bot is initialized. This can be used for setup if you need access to the bot instance.

Source
persisted_chat_ids
Source
persisted_chats
Source
persisted_user_ids
Source
persisted_users
Source
update_chat(chat : Chat) : Chat

Create or update the provided Chat.

Source
update_user(user : User) : User

Create or update the provided User.

Source
user_exists?(user_id : Int) : Bool

Returns true if the user with the provided user_id exists.

Source
user_exists?(username : String) : Bool

Returns true if the user with the provided username exists.

Source