webhook_telegram_bot.helpers
This file contains application helpers.
Module Contents
Functions
|
Set application config. |
|
Return application config. |
|
Return config value by key. |
|
Set database instance into application. |
|
Return database instance from application. |
|
Set TelegramAPI instance into application. |
|
Return TelegramAPI instance from application. |
|
Set template engine instance into application. |
|
Return template engine instance from application. |
|
Return database wrapper instance, according configuration. |
|
Set list of plugin instances into application. |
|
Return list of plugin instances. |
Attributes
- webhook_telegram_bot.helpers.CONFIG_KEY = CONFIG
- webhook_telegram_bot.helpers.DATABASE_KEY = DB
- webhook_telegram_bot.helpers.TELEGRAM_API_KEY = TELEGRAM_API
- webhook_telegram_bot.helpers.TEMPLATE_ENGINE_KEY = TEMPLATE_ENGINE
- webhook_telegram_bot.helpers.PLUGINS_INSTANCES_KEY = PLUGINS_INSTANCES
- webhook_telegram_bot.helpers.set_config(app: aiohttp.web.Application, config: Dict[str, Any]) None
Set application config.
- Parameters
app – application instance
config – application configuration
- Returns
None
- webhook_telegram_bot.helpers.get_config(app: aiohttp.web.Application) Dict[str, Any]
Return application config.
- Parameters
app – application instance
- Returns
application configuration
- webhook_telegram_bot.helpers.get_config_value(app: aiohttp.web.Application, key: str) Optional[Union[str, List[str]]]
Return config value by key.
- Parameters
app – application instance
key – name of config property
key – str
- Returns
value of config property
- webhook_telegram_bot.helpers.set_database(app: aiohttp.web.Application, database: webhook_telegram_bot.database.backends.types.DatabaseWrapperImpl) None
Set database instance into application.
- Parameters
app – application instance
database – database wrapper instance
- Returns
None
- webhook_telegram_bot.helpers.get_database(app: aiohttp.web.Application) webhook_telegram_bot.database.backends.types.DatabaseWrapperImpl
Return database instance from application.
- Parameters
app – application instance
- Returns
database wrapper instance
- webhook_telegram_bot.helpers.set_telegram_api(app: aiohttp.web.Application, telegram_api: webhook_telegram_bot.telegram.telegram_api.TelegramAPI) None
Set TelegramAPI instance into application.
- Parameters
app – application instance
telegram_api – TelegramAPI instance
- Returns
None
- webhook_telegram_bot.helpers.get_telegram_api(app: aiohttp.web.Application) webhook_telegram_bot.telegram.telegram_api.TelegramAPI
Return TelegramAPI instance from application.
- Parameters
app – application instance
- Returns
TelegramAPI instance
- webhook_telegram_bot.helpers.set_template_engine(app: aiohttp.web.Application, template_engine: jinja2.Environment) None
Set template engine instance into application.
- Parameters
app – application instance
template_engine – instance of template engine
- Returns
None
- webhook_telegram_bot.helpers.get_template_engine(app: aiohttp.web.Application) jinja2.Environment
Return template engine instance from application.
- Parameters
app – application instance
- Returns
instance of template engine
- webhook_telegram_bot.helpers.get_db_wrapper_instance(database_engine: str, database_url: str) webhook_telegram_bot.database.backends.types.DatabaseWrapperImpl
Return database wrapper instance, according configuration.
- Parameters
database_engine – path to DatabaseWrapper implementation
database_url – connection string to database
- Returns
database wrapper instance
- webhook_telegram_bot.helpers.set_plugins_instances(app: aiohttp.web.Application, plugins_instances: List[webhook_telegram_bot.plugins.types.AbstractPluginImpl]) None
Set list of plugin instances into application.
- Parameters
app – application instance
plugins_instances – list of plugins instances
- Returns
None
- webhook_telegram_bot.helpers.get_plugins_instances(app: aiohttp.web.Application) List[webhook_telegram_bot.plugins.types.AbstractPluginImpl]
Return list of plugin instances.
- Parameters
app – application instance
- Returns
list of plugins instances