social media crossposting tool. 3rd time's the charm
mastodon
misskey
crossposting
bluesky
1from pathlib import Path
2from typing import Any
3
4from registry import input_factories, output_factories
5
6
7class LazyFactory:
8 def __init__(self, module_path: str, class_name: str, options_class_name: str):
9 self.module_path: str = module_path
10 self.class_name: str = class_name
11 self.options_class_name: str = options_class_name
12
13 def __call__(self, db: Path, d: dict[str, Any]):
14 module = __import__(
15 self.module_path, fromlist=[self.class_name, self.options_class_name]
16 )
17 service_class = getattr(module, self.class_name)
18 options_class = getattr(module, self.options_class_name)
19 return service_class(db, options_class.from_dict(d))
20
21
22def bootstrap():
23 input_factories["mastodon-wss"] = LazyFactory(
24 "mastodon.input", "MastodonInputService", "MastodonInputOptions"
25 )
26 input_factories["misskey-wss"] = LazyFactory(
27 "misskey.input", "MisskeyInputService", "MisskeyInputOptions"
28 )