🔀 Merge pull request #243

Bug: adapter can be register more than once
This commit is contained in:
Ju4tCode 2021-02-26 17:28:04 +08:00 committed by GitHub
commit f9e4d077d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,6 +73,10 @@ class Driver(abc.ABC):
* ``name: str``: 适配器名称用于在连接时进行识别 * ``name: str``: 适配器名称用于在连接时进行识别
* ``adapter: Type[Bot]``: 适配器 Class * ``adapter: Type[Bot]``: 适配器 Class
""" """
if name in self._adapters:
logger.opt(
colors=True).debug(f'Adapter "<y>{name}</y>" already exists')
return
self._adapters[name] = adapter self._adapters[name] = adapter
adapter.register(self, self.config, **kwargs) adapter.register(self, self.config, **kwargs)
logger.opt( logger.opt(