twtb.logic.shared.db#

The package for the database system.

Submodules#

Package Contents#

Classes#

Database

Main class for the data storage (aka database).

DatabaseConfigSection

Database configuration section.

class Database[source]#

Main class for the data storage (aka database).

async subscribe_user(user: int, word: str) bool[source]#

Subscribe user to the word.

Returns:

Whether user was subscribed.

async unsubscribe_user(user: int, word: str) bool[source]#

Unsubscribe user from the word.

Returns:

Whether word was removed.

async add_channel(id: str) bool[source]#

Add channel to our database.

Returns:

Whether channel was added.

async delete_channel(id: str) bool[source]#

Delete channel from our database.

Returns:

Whether channel was deleted.

async get_all_channels() Set[str][source]#

Get all channels from database.

async get_user_words(user_id: int) Set[str][source]#

Get all words, which the user is subscribed to.

async get_all_subscribed_words() Dict[str, Set[int]][source]#

Get all words, that we need to listen.

Returns:

A dict where key is a word to listen, and value - a list of users to forward message.

class DatabaseConfigSection[source]#

Database configuration section.

host: str = localhost[source]#
port: int = 6379[source]#
password: str | None[source]#