vamo_telbot.config.manager

Centralized application configuration manager.

Functions

load_config()

Load application configuration from disk.

save_config(config)

Persist application configuration to disk.

set_config_value(key, value)

Set a single configuration value and persist it to disk.

get_config_value(key[, default])

Retrieve a configuration value by key.

Module Contents

vamo_telbot.config.manager.load_config()

Load application configuration from disk.

Reads the application configuration file defined by SECRETS_FILE_PATH and returns its contents as a dictionary. If the configuration file does not exist, cannot be read, contains invalid JSON, or does not represent a JSON object, an empty dictionary is returned.

This function is intentionally defensive and guarantees that the return value is always a dictionary, making it safe to use as a mutable configuration store by callers.

Returns:

A dictionary containing configuration key-value pairs loaded from disk, or an empty dictionary if the configuration file is missing, invalid, or unreadable.

Return type:

dict[str, Any]

vamo_telbot.config.manager.save_config(config)

Persist application configuration to disk.

Serializes the provided configuration dictionary as JSON and writes it to the configuration file defined by SECRETS_FILE_PATH. The file is written using UTF-8 encoding and pretty-printed formatting to remain human-readable.

This function overwrites the existing configuration file content. Callers are expected to load the current configuration, modify only the required keys, and then save the updated dictionary.

Parameters:

config (dict[str, Any]) – A dictionary containing application configuration key-value pairs to persist.

Return type:

None

vamo_telbot.config.manager.set_config_value(key, value)

Set a single configuration value and persist it to disk.

Loads the existing application configuration, adds or updates the specified key with the provided value, and writes the updated configuration back to the configuration file.

This function preserves all other existing configuration entries by performing a read-modify-write cycle.

Parameters:
  • key (str) – Configuration key to add or update.

  • value (Any) – Value to associate with the given key. The value must be JSON-serializable.

Return type:

None

vamo_telbot.config.manager.get_config_value(key, default=None)

Retrieve a configuration value by key.

Loads the application configuration from disk and returns the value associated with the specified key. If the key does not exist or the configuration file is missing or invalid, the provided default value is returned.

Parameters:
  • key (str) – Configuration key to retrieve.

  • default (Any) – Value to return if the key is not present in the configuration. Defaults to None.

Returns:

The value associated with the given key if it exists; otherwise, the provided default value.

Return type:

Any