15 lines
539 B
Python

from telebot.storage import StateMemoryStorage, StateRedisStorage
from .config import StateStorageConfig
def get_state_storage(config: StateStorageConfig):
if config.type == "memory":
state_storage = StateMemoryStorage()
elif config.type == "redis":
state_storage = StateRedisStorage(config.redis_host, config.redis_port,
config.redis_db, config.redis_pass)
else:
raise RuntimeWarning(f"Unknown state storage type: '{config.type}'")
return state_storage