bot-storage
Storage - an object that allows you to save the states and data of users.
The storage.py file describes the abstract class BaseStorage, inheriting from which, you can implement your own storage (eg DBStorage or JSONStorage).
Such storages, however, will obviously not be more efficient than the already implemented RedisStorage.
Installation:
pip install bot-storage
Setting up
YourProject/tbot/storage.py
from os import getenv
from bot_storage.storage import RedisStorage
storage = RedisStorage(
host=getenv('REDIS_HOST', 'localhost'),
username=getenv('REDIS_USER', None),
password=getenv('REDIS_PASSWORD', None)
)
YourProject/settings.py
from tbot.storage import storage
# Your storage for user states & data
BOT_STORAGE = storage
Start Redis
redis-server
Usage
For example YourProject/tbot/handlers.py
from telebot import types
from telebot.apihelper import ApiTelegramException
from tbot_base.bot import tbot
from .storage import storage as st
@tbot.message_handler(
func=lambda msg: st.get_user_state(msg.from_user.id) == 'some_state#'
)
def send_faq_search(msg: types.Message):
tbot.send_message(chat_id=msg.from_user.id, text='Hello!')
Metadata
Release files for bot-storage 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bot-storage-1.0.1.tar.gz | 3.2 kB | Without provenance | Details for bot-storage-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bot_storage-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for bot_storage-1.0.1-py3-none-any.whl |
Total release size: 6.5 kB
Release files / bot-storage-1.0.1.tar.gz
| Download URL | bot-storage-1.0.1.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9eab0a36a4e7903822133567d3b2ae7b4a789c551773d45cc2977739e4cd2aac
|
|
BLAKE2b-256 checksum How to use checksums |
e66cfac7d50ab227fa45e6ee4d4739342b1613273d56ed1bd62f182412897f7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Release files / bot_storage-1.0.1-py3-none-any.whl
| Download URL | bot_storage-1.0.1-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cadf76d22cd341bb1b23e8f4df9b3bc5bdbe715b9e3f4420a8dd7cf55480912c
|
|
BLAKE2b-256 checksum How to use checksums |
e7d67e7c9af87017e9141ebca88124848ea18ef6a541566dd1f5acd8c252f138
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Security for bot-storage 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.