added config.port

This commit is contained in:
Alexey Sokolov
2022-02-10 16:27:27 +03:00
parent 4739b8963a
commit 125198a0e2
4 changed files with 14 additions and 3 deletions

View File

@@ -8,10 +8,12 @@ class Config:
Notifier config dataclass.
* `base_url`: url of domain
* `port`: server port (default **3001**)
* `teletoken`: telegram api token.
* `param bot_owner`: telegram id of bot owner.
* `bot_owner`: telegram id of bot owner.
"""
base_url: str
port: int
teletoken: str
bot_owner: int
@@ -45,6 +47,12 @@ _base_url = getenv('LTLNOTIFIER_BASE_URL')
if not _base_url:
raise ConfigError('virtual environment LTLNOTIFIER_BASE_URL not set')
config = Config(teletoken=_teletoken, bot_owner=_bot_owner, base_url=_base_url)
_port = getenv('LTLNOTIFIER_PORT')
_port = int(_port) if _port.isdigit() else 3001
__all__ = ['Config', 'config']
config = Config(teletoken=_teletoken,
port=_port,
bot_owner=_bot_owner,
base_url=_base_url)
__all__ = ('Config', 'config')

View File

@@ -7,3 +7,6 @@ from config import config
telegram_bot = Bot(token=config.teletoken)
telegram_dispatcher = Dispatcher(telegram_bot)
telegram_dispatcher.middleware.setup(LoggingMiddleware())
__all__ = ('telegram_bot', telegram_dispatcher)

0
web/routes.py Normal file
View File

0
web/views.py Normal file
View File