twtb.logic.shared.db.channels_info#

Module for channels_info attribute.

Module Contents#

Classes#

ChannelInfo

Class for channel info into object instead of dict.

ChannelInfoInDB

Class for storing channel info in database.

class ChannelInfo[source]#

Class for channel info into object instead of dict.

title: str[source]#
username: str[source]#
to_json() str[source]#

Transforms self to JSON string.

classmethod from_json(data: str) typing_extensions.Self[source]#

Creates instance from JSON string.

__post_init__() None[source]#

The annotations in telethon say that username can be None.

This will check for that, and report into logs.

exception ChannelNotFoundOrIsInvalidError(channel_name: str)[source]#

Bases: Exception

Exception raised when you try to get and save channel, which doesn’t exist or is invalid.

exception ProvidedIdIsNotAChannelError(channel_name: str, actual_type_name: str)[source]#

Bases: Exception

Exception raised when you try to get and save something, which is not a channel.

class ChannelInfoInDB(connection: redis.asyncio.Redis[bytes])[source]#

Class for storing channel info in database.

async get(id: str, *, _optimize: bool = True) ChannelInfo | None[source]#

Get channel info from database.

async set(id: str, value: ChannelInfo, *, expire: float | None = None, _optimize: bool = True) bool[source]#

Set channel info in database.

async get_and_save(id: str, client: telethon.TelegramClient) ChannelInfo[source]#

Get channel info from database, and save it if it’s not there.