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:

Constructors

Instance Method Summary

Instance methods inherited from class Tourmaline::HashPersistence

chat_exists?(chat_id : Int) : Bool
chat_exists?(username : String) : Bool
chat_exists?
, cleanup cleanup, filename : String filename, get_chat(chat_id : Int) : Chat?
get_chat(username : String) : Chat?
get_chat
, get_user(user_id : Int) : User?
get_user(username : String) : User?
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) : Bool
chat_exists?(username : String) : Bool
chat_exists?
, cleanup cleanup, get_chat(chat_id : Int) : Chat?
get_chat(username : String) : Chat?
get_chat
, get_user(user_id : Int) : User?
get_user(username : String) : User?
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?(usename : String) : Bool
user_exists?

Constructor Detail

def self.new(filename = "tourmaline_persistence.json") #

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 filename : String #

def filename=(filename : String) #

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.