Moved telegram part to telegram package
This commit is contained in:
18
config.py
18
config.py
@@ -8,11 +8,11 @@ class Config:
|
||||
Notifier config dataclass.
|
||||
|
||||
* `base_url`: url of domain
|
||||
* `api_token`: telegram api token.
|
||||
* `teletoken`: telegram api token.
|
||||
* `param bot_owner`: telegram id of bot owner.
|
||||
"""
|
||||
base_url: str
|
||||
api_token: str
|
||||
teletoken: str
|
||||
bot_owner: int
|
||||
|
||||
|
||||
@@ -20,13 +20,13 @@ class ConfigError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
_api_token = getenv('LTLNOTIFIER_API_TOKEN')
|
||||
print(_api_token[9])
|
||||
_teletoken = getenv('LTLNOTIFIER_TELETOKEN')
|
||||
print(_teletoken[9])
|
||||
# Check api token
|
||||
if not _api_token:
|
||||
raise ConfigError('virtual environment LTLNOTIFIER_API_TOKEN not set.')
|
||||
if len(_api_token) != 45 or _api_token[9] != ':' or not _api_token[:9].isdigit():
|
||||
raise ConfigError('virtual environment LTLNOTIFIER_API_TOKEN incorrect.')
|
||||
if not _teletoken:
|
||||
raise ConfigError('virtual environment LTLNOTIFIER_TELETOKEN not set.')
|
||||
if len(_teletoken) != 45 or _teletoken[9] != ':' or not _teletoken[:9].isdigit():
|
||||
raise ConfigError('virtual environment LTLNOTIFIER_TELETOKEN incorrect.')
|
||||
|
||||
_bot_owner = getenv('LTLNOTIFIER_BOT_OWNER')
|
||||
print(_bot_owner)
|
||||
@@ -45,6 +45,6 @@ _base_url = getenv('LTLNOTIFIER_BASE_URL')
|
||||
if not _base_url:
|
||||
raise ConfigError('virtual environment LTLNOTIFIER_BASE_URL not set')
|
||||
|
||||
config = Config(api_token=_api_token, bot_owner=_bot_owner, base_url=_base_url)
|
||||
config = Config(teletoken=_teletoken, bot_owner=_bot_owner, base_url=_base_url)
|
||||
|
||||
__all__ = ['Config', 'config']
|
||||
|
||||
Reference in New Issue
Block a user