16 lines
423 B
Python
16 lines
423 B
Python
from collections.abc import Awaitable, Callable
|
|
from dataclasses import dataclass, field
|
|
|
|
|
|
@dataclass
|
|
class Plugin:
|
|
id: str
|
|
title: str
|
|
description: str = ""
|
|
poll_seconds: int = 5
|
|
fragment_fn: Callable[[], Awaitable[str]] | None = field(default=None)
|
|
|
|
async def fragment(self) -> str:
|
|
if self.fragment_fn is None:
|
|
raise NotImplementedError
|
|
return await self.fragment_fn()
|