From 8c9e096a8441e73d4a2d965e20385f723ab31f9d Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Fri, 26 Feb 2021 17:22:39 +0800 Subject: [PATCH] :bug: ignore adapter register with same name --- nonebot/drivers/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nonebot/drivers/__init__.py b/nonebot/drivers/__init__.py index 134b2078..efa6bc71 100644 --- a/nonebot/drivers/__init__.py +++ b/nonebot/drivers/__init__.py @@ -73,6 +73,10 @@ class Driver(abc.ABC): * ``name: str``: 适配器名称,用于在连接时进行识别 * ``adapter: Type[Bot]``: 适配器 Class """ + if name in self._adapters: + logger.opt( + colors=True).debug(f'Adapter "{name}" already exists') + return self._adapters[name] = adapter adapter.register(self, self.config, **kwargs) logger.opt(