|
@@ -27,6 +27,7 @@ __all__ = [
|
|
|
"Debugging",
|
|
|
"Config",
|
|
|
"Lazy",
|
|
|
+ "Const",
|
|
|
]
|
|
|
|
|
|
MessageInjector = Simple[Message](lambda m, c: m)
|
|
@@ -46,7 +47,6 @@ Respond = Simple[Callable[[], Coroutine[None, None, None]]](lambda m, c: c.respo
|
|
|
LoggerInjector = Simple[Logger](lambda m, c: c.logger)
|
|
|
Debugging = Simple[Optional[str]](lambda m, c: c.get_debugging())
|
|
|
|
|
|
-
|
|
|
class Config(Injector[Any]):
|
|
|
def __init__(self, key: str):
|
|
|
self.key = key
|
|
@@ -84,3 +84,10 @@ class Lazy(InjectorWithCleanup[Callable[[], Coroutine[None, None, Dep]]]):
|
|
|
async def cleanup(self, dep: Callable[[], Coroutine[None, None, Dep]]):
|
|
|
if isinstance(self.deferred, InjectorWithCleanup) and dep._calculated is not None:
|
|
|
await self.deferred.cleanup(dep._calculated)
|
|
|
+
|
|
|
+class Const(Injector[Dep]):
|
|
|
+ def __init__(self, const: Dep):
|
|
|
+ self.const = const
|
|
|
+
|
|
|
+ async def inject(self, message: Message, context: Context) -> Dep:
|
|
|
+ return self.const
|