WIP: Matrix support #175
@ -21,26 +21,32 @@ logger: Logger = logging.getLogger(__name__)
|
|||||||
class MatrixBot(Bot):
|
class MatrixBot(Bot):
|
||||||
@override
|
@override
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: Dict[str, Any] | None = None,
|
config: Dict[str, Any] | None = None,
|
||||||
config_path: str | Path = Path("config.json"),
|
config_path: str | Path = Path("config.json"),
|
||||||
locales_root: str | Path | None = None,
|
locales_root: str | Path | None = None,
|
||||||
scheduler: AsyncIOScheduler | BackgroundScheduler | None = None,
|
scheduler: AsyncIOScheduler | BackgroundScheduler | None = None,
|
||||||
smbl_creds: Creds = None,
|
smbl_creds: Creds = None,
|
||||||
smbl_config: Config = None,
|
smbl_config: Config = None,
|
||||||
):
|
):
|
||||||
self.config: Dict[str, Any] = config if config is not None else json_read(config_path)
|
self.bot_config: Dict[str, Any] = config if config is not None else json_read(config_path)
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
creds=smbl_creds if smbl_creds is not None else Creds(homeserver=self.config["homeserver"],
|
creds=(
|
||||||
username=self.config["username"],
|
smbl_creds
|
||||||
password=self.config["password"],
|
if smbl_creds is not None
|
||||||
device_name=self.config["device_name"]),
|
else Creds(
|
||||||
|
homeserver=self.bot_config["bot"]["homeserver"],
|
||||||
|
username=self.bot_config["bot"]["username"],
|
||||||
|
password=self.bot_config["bot"]["password"],
|
||||||
|
device_name=self.bot_config["bot"]["device_name"],
|
||||||
|
)
|
||||||
|
),
|
||||||
config=smbl_config,
|
config=smbl_config,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.bot_locale: BotLocale = BotLocale(
|
self.bot_locale: BotLocale = BotLocale(
|
||||||
default_locale=self.config["locale"],
|
default_locale=self.bot_config["locale"],
|
||||||
locales_root=(Path("locale") if locales_root is None else locales_root),
|
locales_root=(Path("locale") if locales_root is None else locales_root),
|
||||||
)
|
)
|
||||||
self.default_locale: str = self.bot_locale.default
|
self.default_locale: str = self.bot_locale.default
|
||||||
@ -53,7 +59,9 @@ class MatrixBot(Bot):
|
|||||||
self.scheduler: AsyncIOScheduler | BackgroundScheduler | None = scheduler
|
self.scheduler: AsyncIOScheduler | BackgroundScheduler | None = scheduler
|
||||||
|
|
||||||
@override
|
@override
|
||||||
def run(self, scheduler_start: bool = True, scheduler_shutdown: bool = True, scheduler_wait: bool = True) -> None:
|
def run(
|
||||||
|
self, scheduler_start: bool = True, scheduler_shutdown: bool = True, scheduler_wait: bool = True
|
||||||
|
) -> None:
|
||||||
if self.scheduler is not None and scheduler_start:
|
if self.scheduler is not None and scheduler_start:
|
||||||
self.scheduler.start()
|
self.scheduler.start()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user