its-matrix-bot/its_matrix_bot/config.py

32 lines
763 B
Python
Raw Permalink Normal View History

2022-03-27 19:17:21 +02:00
import toml
from typing import List
2022-03-27 19:17:21 +02:00
class Config:
command_prefix: str
matrix_homeserver: str
matrix_user: str
matrix_access_token: str
spaceping_token: str
isitopen_announce_rooms: List[str]
2022-03-27 19:17:21 +02:00
def __init__(self, path=None):
if path is None:
path = "/etc/itsyndikat-bot.toml"
config = toml.load(path)
2022-03-27 19:35:40 +02:00
self.command_prefix = config["app"]["command_prefix"]
2022-03-27 19:17:21 +02:00
2022-03-27 19:35:40 +02:00
matrix = config["matrix"]
self.matrix_homeserver = matrix["homeserver"]
self.matrix_username = matrix["username"]
self.matrix_access_token = matrix["access_token"]
2022-03-27 19:17:21 +02:00
2022-03-27 19:35:40 +02:00
self.spaceping_token = config["spaceping"]["api_token"]
self.isitopen_announce_rooms = config["isitopen"]["announce_rooms"]