Add configuration for plugins

This commit is contained in:
Tulir Asokan 2018-10-20 18:39:16 +03:00
parent ac5f059ef4
commit b29a7d186e
7 changed files with 57 additions and 9 deletions

View file

@ -41,6 +41,7 @@ class ZippedPluginLoader(PluginLoader):
main_module: str
_loaded: Type[PluginClass]
_importer: zipimporter
_file: ZipFile
def __init__(self, path: str) -> None:
super().__init__()
@ -76,10 +77,13 @@ class ZippedPluginLoader(PluginLoader):
f"id='{self.id}' "
f"loaded={self._loaded is not None}>")
def read_file(self, path: str) -> bytes:
return self._file.read(path)
def _load_meta(self) -> None:
try:
file = ZipFile(self.path)
data = file.read("maubot.ini")
self._file = ZipFile(self.path)
data = self._file.read("maubot.ini")
except FileNotFoundError as e:
raise MaubotZipImportError("Maubot plugin not found") from e
except BadZipFile as e: