fix: make bot initializable without recorder
This commit is contained in:
@@ -27,7 +27,8 @@ def main():
|
||||
|
||||
app: QApplication = QApplication(sys.argv)
|
||||
recorder: RecorderWindow = RecorderWindow("localhost", 5000)
|
||||
bot: ExampleBot = ExampleBot(recorder)
|
||||
bot: ExampleBot = ExampleBot()
|
||||
bot.set_recorder(recorder)
|
||||
|
||||
app.aboutToQuit.connect(recorder.shutdown)
|
||||
recorder.register_bot(bot)
|
||||
|
||||
16
src/bot.py
16
src/bot.py
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from src.snapshot import Snapshot
|
||||
|
||||
@@ -9,8 +9,18 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
class Bot:
|
||||
def __init__(self, recorder: RecorderWindow):
|
||||
self.recorder: RecorderWindow = recorder
|
||||
def __init__(self):
|
||||
self._recorder: Optional[RecorderWindow] = None
|
||||
|
||||
@property
|
||||
def recorder(self) -> RecorderWindow:
|
||||
if self._recorder is None:
|
||||
raise RuntimeError(
|
||||
"Bot does not have a recorder. Call Bot.set_recorder to set one")
|
||||
return self._recorder
|
||||
|
||||
def set_recorder(self, recorder: RecorderWindow):
|
||||
self._recorder = recorder
|
||||
|
||||
def on_snapshot_received(self, snapshot: Snapshot):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user