Implement instance view

This commit is contained in:
Tulir Asokan 2018-11-10 16:33:12 +02:00
parent 0a406ac071
commit b0d782906b
13 changed files with 478 additions and 99 deletions

View file

@ -186,10 +186,27 @@ class PluginInstance:
self.db_instance.primary_user = client.id
self.client.references.remove(self)
self.client = client
self.client.references.add(self)
await self.start()
self.log.debug(f"Primary user switched to {self.client.id}")
return True
async def update_type(self, type: str) -> bool:
if not type or type == self.type:
return True
try:
loader = PluginLoader.find(type)
except KeyError:
return False
await self.stop()
self.db_instance.type = loader.id
self.loader.references.remove(self)
self.loader = loader
self.loader.references.add(self)
await self.start()
self.log.debug(f"Type switched to {self.loader.id}")
return True
async def update_started(self, started: bool) -> None:
if started is not None and started != self.started:
await (self.start() if started else self.stop())