twtb.logic.shared.db.sharing_message
#
Makes possible sharing messages between client and bot.
Because almost all IDs in Telegram are unique only to one bot. Here, we firstly send message to the shared chat, from where bot reforwards message to the end users.
This is the only way to share message ID that I found.
Module Contents#
Classes#
Class for sharing message in database. |
Functions#
|
FNV-1a 64-bit hash implementation. |
- hash_with_fnv64(string: str) → str[source]#
FNV-1a 64-bit hash implementation.
It is a fast non-cryptographic hash function, which is good for us to transform the message data into short form.
See also
Was copied from `https://gist.github.com/Cilyan/9424144`_ and `https://stackoverflow.com/a/22000293`_.
- class SharingMessageInDB(connection: redis.asyncio.Redis[bytes])[source]#
Class for sharing message in database.
- async set(message_hash: str, users_to_send: Set[int]) → bool[source]#
Set users to send the message in database.
- Returns:
Whether the message is duplicate. The function will raise warning if it’s
True
.
- async get_shared_chat(*, both: bool) → Tuple[int | None, int | None][source]#
- async get_shared_chat(*, client: bool) → int | None
- async get_shared_chat(*, bot: bool) → int | None
Get shared chat id as bot and client.
- Returns:
Tuple, where first element is bot’s chat id and second is client’s chat id.