prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Bug: `Adapter.bot_disconnect` 不应允许关闭其他适配器创建的 bot
  **描述问题：**
  
  当前的 `bot_disconnect` 只会根据 `bot.self_id` 关闭对应 bot。如果 `OneBot V12` 适配器调用 `bot_disconnect` 也能将 `OneBot V11` 适配器创建的 bot 移除。
  
  **如何复现？**
  
  <https://github.com/nonebot/adapter-onebot/pull/45>
  <https://github.com/he0119/CoolQBot/issues/264>
  
  **期望的结果**
  
  如果关闭的 bot 不属于当前适配器，则跳过或者报错。
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `nonebot/internal/adapter/adapter.py`
  Content:
  ```
  1 import abc
  2 from contextlib import asynccontextmanager
  3 from typing import Any, Dict, AsyncGenerator
  4 
  5 from nonebot.config import Config
  6 from nonebot.internal.driver import (
  7     Driver,
  8     Request,
  9     Response,
  10     WebSocket,
  11     ForwardDriver,
  12     ReverseDriver,
  13     HTTPServerSetup,
  14     WebSocketServerSetup,
  15 )
  16 
  17 from .bot import Bot
  18 
  19 
  20 class Adapter(abc.ABC):
  21     """协议适配器基类。
  22 
  23     通常，在 Adapter 中编写协议通信相关代码，如: 建立通信连接、处理接收与发送 data 等。
  24 
  25     参数:
  26         driver: {ref}`nonebot.drivers.Driver` 实例
  27         kwargs: 其他由 {ref}`nonebot.drivers.Driver.register_adapter` 传入的额外参数
  28     """
  29 
  30     def __init__(self, driver: Driver, **kwargs: Any):
  31         self.driver: Driver = driver
  32         """{ref}`nonebot.drivers.Driver` 实例"""
  33         self.bots: Dict[str, Bot] = {}
  34         """本协议适配器已建立连接的 {ref}`nonebot.adapters.Bot` 实例"""
  35 
  36     def __repr__(self) -> str:
  37         return f"Adapter(name={self.get_name()!r})"
  38 
  39     @classmethod
  40     @abc.abstractmethod
  41     def get_name(cls) -> str:
  42         """当前协议适配器的名称"""
  43         raise NotImplementedError
  44 
  45     @property
  46     def config(self) -> Config:
  47         """全局 NoneBot 配置"""
  48         return self.driver.config
  49 
  50     def bot_connect(self, bot: Bot) -> None:
  51         """告知 NoneBot 建立了一个新的 {ref}`nonebot.adapters.Bot` 连接。
  52 
  53         当有新的 {ref}`nonebot.adapters.Bot` 实例连接建立成功时调用。
  54 
  55         参数:
  56             bot: {ref}`nonebot.adapters.Bot` 实例
  57         """
  58         self.driver._bot_connect(bot)
  59         self.bots[bot.self_id] = bot
  60 
  61     def bot_disconnect(self, bot: Bot) -> None:
  62         """告知 NoneBot {ref}`nonebot.adapters.Bot` 连接已断开。
  63 
  64         当有 {ref}`nonebot.adapters.Bot` 实例连接断开时调用。
  65 
  66         参数:
  67             bot: {ref}`nonebot.adapters.Bot` 实例
  68         """
  69         self.driver._bot_disconnect(bot)
  70         self.bots.pop(bot.self_id, None)
  71 
  72     def setup_http_server(self, setup: HTTPServerSetup):
  73         """设置一个 HTTP 服务器路由配置"""
  74         if not isinstance(self.driver, ReverseDriver):
  75             raise TypeError("Current driver does not support http server")
  76         self.driver.setup_http_server(setup)
  77 
  78     def setup_websocket_server(self, setup: WebSocketServerSetup):
  79         """设置一个 WebSocket 服务器路由配置"""
  80         if not isinstance(self.driver, ReverseDriver):
  81             raise TypeError("Current driver does not support websocket server")
  82         self.driver.setup_websocket_server(setup)
  83 
  84     async def request(self, setup: Request) -> Response:
  85         """进行一个 HTTP 客户端请求"""
  86         if not isinstance(self.driver, ForwardDriver):
  87             raise TypeError("Current driver does not support http client")
  88         return await self.driver.request(setup)
  89 
  90     @asynccontextmanager
  91     async def websocket(self, setup: Request) -> AsyncGenerator[WebSocket, None]:
  92         """建立一个 WebSocket 客户端连接请求"""
  93         if not isinstance(self.driver, ForwardDriver):
  94             raise TypeError("Current driver does not support websocket client")
  95         async with self.driver.websocket(setup) as ws:
  96             yield ws
  97 
  98     @abc.abstractmethod
  99     async def _call_api(self, bot: Bot, api: str, **data: Any) -> Any:
  100         """`Adapter` 实际调用 api 的逻辑实现函数，实现该方法以调用 api。
  101 
  102         参数:
  103             api: API 名称
  104             data: API 数据
  105         """
  106         raise NotImplementedError
  107 
  108 
  109 __autodoc__ = {"Adapter._call_api": True}
  110
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/nonebot/internal/adapter/adapter.py b/nonebot/internal/adapter/adapter.py
  --- a/nonebot/internal/adapter/adapter.py
  +++ b/nonebot/internal/adapter/adapter.py
  @@ -66,8 +66,9 @@
           参数:
               bot: {ref}`nonebot.adapters.Bot` 实例
           """
  +        if self.bots.pop(bot.self_id, None) is None:
  +            raise RuntimeError(f"{bot} not found in adapter {self.get_name()}")
           self.driver._bot_disconnect(bot)
  -        self.bots.pop(bot.self_id, None)
   
       def setup_http_server(self, setup: HTTPServerSetup):
           """设置一个 HTTP 服务器路由配置"""
  
verification_info: {"golden_diff": "diff --git a/nonebot/internal/adapter/adapter.py b/nonebot/internal/adapter/adapter.py\n--- a/nonebot/internal/adapter/adapter.py\n+++ b/nonebot/internal/adapter/adapter.py\n@@ -66,8 +66,9 @@\n         \u53c2\u6570:\n             bot: {ref}`nonebot.adapters.Bot` \u5b9e\u4f8b\n         \"\"\"\n+        if self.bots.pop(bot.self_id, None) is None:\n+            raise RuntimeError(f\"{bot} not found in adapter {self.get_name()}\")\n         self.driver._bot_disconnect(bot)\n-        self.bots.pop(bot.self_id, None)\n \n     def setup_http_server(self, setup: HTTPServerSetup):\n         \"\"\"\u8bbe\u7f6e\u4e00\u4e2a HTTP \u670d\u52a1\u5668\u8def\u7531\u914d\u7f6e\"\"\"\n", "issue": "Bug: `Adapter.bot_disconnect` \u4e0d\u5e94\u5141\u8bb8\u5173\u95ed\u5176\u4ed6\u9002\u914d\u5668\u521b\u5efa\u7684 bot\n**\u63cf\u8ff0\u95ee\u9898\uff1a**\r\n\r\n\u5f53\u524d\u7684 `bot_disconnect` \u53ea\u4f1a\u6839\u636e `bot.self_id` \u5173\u95ed\u5bf9\u5e94 bot\u3002\u5982\u679c `OneBot V12` \u9002\u914d\u5668\u8c03\u7528 `bot_disconnect` \u4e5f\u80fd\u5c06 `OneBot V11` \u9002\u914d\u5668\u521b\u5efa\u7684 bot \u79fb\u9664\u3002\r\n\r\n**\u5982\u4f55\u590d\u73b0\uff1f**\r\n\r\n<https://github.com/nonebot/adapter-onebot/pull/45>\r\n<https://github.com/he0119/CoolQBot/issues/264>\r\n\r\n**\u671f\u671b\u7684\u7ed3\u679c**\r\n\r\n\u5982\u679c\u5173\u95ed\u7684 bot \u4e0d\u5c5e\u4e8e\u5f53\u524d\u9002\u914d\u5668\uff0c\u5219\u8df3\u8fc7\u6216\u8005\u62a5\u9519\u3002\r\n\n", "before_files": [{"content": "import abc\nfrom contextlib import asynccontextmanager\nfrom typing import Any, Dict, AsyncGenerator\n\nfrom nonebot.config import Config\nfrom nonebot.internal.driver import (\n    Driver,\n    Request,\n    Response,\n    WebSocket,\n    ForwardDriver,\n    ReverseDriver,\n    HTTPServerSetup,\n    WebSocketServerSetup,\n)\n\nfrom .bot import Bot\n\n\nclass Adapter(abc.ABC):\n    \"\"\"\u534f\u8bae\u9002\u914d\u5668\u57fa\u7c7b\u3002\n\n    \u901a\u5e38\uff0c\u5728 Adapter \u4e2d\u7f16\u5199\u534f\u8bae\u901a\u4fe1\u76f8\u5173\u4ee3\u7801\uff0c\u5982: \u5efa\u7acb\u901a\u4fe1\u8fde\u63a5\u3001\u5904\u7406\u63a5\u6536\u4e0e\u53d1\u9001 data \u7b49\u3002\n\n    \u53c2\u6570:\n        driver: {ref}`nonebot.drivers.Driver` \u5b9e\u4f8b\n        kwargs: \u5176\u4ed6\u7531 {ref}`nonebot.drivers.Driver.register_adapter` \u4f20\u5165\u7684\u989d\u5916\u53c2\u6570\n    \"\"\"\n\n    def __init__(self, driver: Driver, **kwargs: Any):\n        self.driver: Driver = driver\n        \"\"\"{ref}`nonebot.drivers.Driver` \u5b9e\u4f8b\"\"\"\n        self.bots: Dict[str, Bot] = {}\n        \"\"\"\u672c\u534f\u8bae\u9002\u914d\u5668\u5df2\u5efa\u7acb\u8fde\u63a5\u7684 {ref}`nonebot.adapters.Bot` \u5b9e\u4f8b\"\"\"\n\n    def __repr__(self) -> str:\n        return f\"Adapter(name={self.get_name()!r})\"\n\n    @classmethod\n    @abc.abstractmethod\n    def get_name(cls) -> str:\n        \"\"\"\u5f53\u524d\u534f\u8bae\u9002\u914d\u5668\u7684\u540d\u79f0\"\"\"\n        raise NotImplementedError\n\n    @property\n    def config(self) -> Config:\n        \"\"\"\u5168\u5c40 NoneBot \u914d\u7f6e\"\"\"\n        return self.driver.config\n\n    def bot_connect(self, bot: Bot) -> None:\n        \"\"\"\u544a\u77e5 NoneBot \u5efa\u7acb\u4e86\u4e00\u4e2a\u65b0\u7684 {ref}`nonebot.adapters.Bot` \u8fde\u63a5\u3002\n\n        \u5f53\u6709\u65b0\u7684 {ref}`nonebot.adapters.Bot` \u5b9e\u4f8b\u8fde\u63a5\u5efa\u7acb\u6210\u529f\u65f6\u8c03\u7528\u3002\n\n        \u53c2\u6570:\n            bot: {ref}`nonebot.adapters.Bot` \u5b9e\u4f8b\n        \"\"\"\n        self.driver._bot_connect(bot)\n        self.bots[bot.self_id] = bot\n\n    def bot_disconnect(self, bot: Bot) -> None:\n        \"\"\"\u544a\u77e5 NoneBot {ref}`nonebot.adapters.Bot` \u8fde\u63a5\u5df2\u65ad\u5f00\u3002\n\n        \u5f53\u6709 {ref}`nonebot.adapters.Bot` \u5b9e\u4f8b\u8fde\u63a5\u65ad\u5f00\u65f6\u8c03\u7528\u3002\n\n        \u53c2\u6570:\n            bot: {ref}`nonebot.adapters.Bot` \u5b9e\u4f8b\n        \"\"\"\n        self.driver._bot_disconnect(bot)\n        self.bots.pop(bot.self_id, None)\n\n    def setup_http_server(self, setup: HTTPServerSetup):\n        \"\"\"\u8bbe\u7f6e\u4e00\u4e2a HTTP \u670d\u52a1\u5668\u8def\u7531\u914d\u7f6e\"\"\"\n        if not isinstance(self.driver, ReverseDriver):\n            raise TypeError(\"Current driver does not support http server\")\n        self.driver.setup_http_server(setup)\n\n    def setup_websocket_server(self, setup: WebSocketServerSetup):\n        \"\"\"\u8bbe\u7f6e\u4e00\u4e2a WebSocket \u670d\u52a1\u5668\u8def\u7531\u914d\u7f6e\"\"\"\n        if not isinstance(self.driver, ReverseDriver):\n            raise TypeError(\"Current driver does not support websocket server\")\n        self.driver.setup_websocket_server(setup)\n\n    async def request(self, setup: Request) -> Response:\n        \"\"\"\u8fdb\u884c\u4e00\u4e2a HTTP \u5ba2\u6237\u7aef\u8bf7\u6c42\"\"\"\n        if not isinstance(self.driver, ForwardDriver):\n            raise TypeError(\"Current driver does not support http client\")\n        return await self.driver.request(setup)\n\n    @asynccontextmanager\n    async def websocket(self, setup: Request) -> AsyncGenerator[WebSocket, None]:\n        \"\"\"\u5efa\u7acb\u4e00\u4e2a WebSocket \u5ba2\u6237\u7aef\u8fde\u63a5\u8bf7\u6c42\"\"\"\n        if not isinstance(self.driver, ForwardDriver):\n            raise TypeError(\"Current driver does not support websocket client\")\n        async with self.driver.websocket(setup) as ws:\n            yield ws\n\n    @abc.abstractmethod\n    async def _call_api(self, bot: Bot, api: str, **data: Any) -> Any:\n        \"\"\"`Adapter` \u5b9e\u9645\u8c03\u7528 api \u7684\u903b\u8f91\u5b9e\u73b0\u51fd\u6570\uff0c\u5b9e\u73b0\u8be5\u65b9\u6cd5\u4ee5\u8c03\u7528 api\u3002\n\n        \u53c2\u6570:\n            api: API \u540d\u79f0\n            data: API \u6570\u636e\n        \"\"\"\n        raise NotImplementedError\n\n\n__autodoc__ = {\"Adapter._call_api\": True}\n", "path": "nonebot/internal/adapter/adapter.py"}], "after_files": [{"content": "import abc\nfrom contextlib import asynccontextmanager\nfrom typing import Any, Dict, AsyncGenerator\n\nfrom nonebot.config import Config\nfrom nonebot.internal.driver import (\n    Driver,\n    Request,\n    Response,\n    WebSocket,\n    ForwardDriver,\n    ReverseDriver,\n    HTTPServerSetup,\n    WebSocketServerSetup,\n)\n\nfrom .bot import Bot\n\n\nclass Adapter(abc.ABC):\n    \"\"\"\u534f\u8bae\u9002\u914d\u5668\u57fa\u7c7b\u3002\n\n    \u901a\u5e38\uff0c\u5728 Adapter \u4e2d\u7f16\u5199\u534f\u8bae\u901a\u4fe1\u76f8\u5173\u4ee3\u7801\uff0c\u5982: \u5efa\u7acb\u901a\u4fe1\u8fde\u63a5\u3001\u5904\u7406\u63a5\u6536\u4e0e\u53d1\u9001 data \u7b49\u3002\n\n    \u53c2\u6570:\n        driver: {ref}`nonebot.drivers.Driver` \u5b9e\u4f8b\n        kwargs: \u5176\u4ed6\u7531 {ref}`nonebot.drivers.Driver.register_adapter` \u4f20\u5165\u7684\u989d\u5916\u53c2\u6570\n    \"\"\"\n\n    def __init__(self, driver: Driver, **kwargs: Any):\n        self.driver: Driver = driver\n        \"\"\"{ref}`nonebot.drivers.Driver` \u5b9e\u4f8b\"\"\"\n        self.bots: Dict[str, Bot] = {}\n        \"\"\"\u672c\u534f\u8bae\u9002\u914d\u5668\u5df2\u5efa\u7acb\u8fde\u63a5\u7684 {ref}`nonebot.adapters.Bot` \u5b9e\u4f8b\"\"\"\n\n    def __repr__(self) -> str:\n        return f\"Adapter(name={self.get_name()!r})\"\n\n    @classmethod\n    @abc.abstractmethod\n    def get_name(cls) -> str:\n        \"\"\"\u5f53\u524d\u534f\u8bae\u9002\u914d\u5668\u7684\u540d\u79f0\"\"\"\n        raise NotImplementedError\n\n    @property\n    def config(self) -> Config:\n        \"\"\"\u5168\u5c40 NoneBot \u914d\u7f6e\"\"\"\n        return self.driver.config\n\n    def bot_connect(self, bot: Bot) -> None:\n        \"\"\"\u544a\u77e5 NoneBot \u5efa\u7acb\u4e86\u4e00\u4e2a\u65b0\u7684 {ref}`nonebot.adapters.Bot` \u8fde\u63a5\u3002\n\n        \u5f53\u6709\u65b0\u7684 {ref}`nonebot.adapters.Bot` \u5b9e\u4f8b\u8fde\u63a5\u5efa\u7acb\u6210\u529f\u65f6\u8c03\u7528\u3002\n\n        \u53c2\u6570:\n            bot: {ref}`nonebot.adapters.Bot` \u5b9e\u4f8b\n        \"\"\"\n        self.driver._bot_connect(bot)\n        self.bots[bot.self_id] = bot\n\n    def bot_disconnect(self, bot: Bot) -> None:\n        \"\"\"\u544a\u77e5 NoneBot {ref}`nonebot.adapters.Bot` \u8fde\u63a5\u5df2\u65ad\u5f00\u3002\n\n        \u5f53\u6709 {ref}`nonebot.adapters.Bot` \u5b9e\u4f8b\u8fde\u63a5\u65ad\u5f00\u65f6\u8c03\u7528\u3002\n\n        \u53c2\u6570:\n            bot: {ref}`nonebot.adapters.Bot` \u5b9e\u4f8b\n        \"\"\"\n        if self.bots.pop(bot.self_id, None) is None:\n            raise RuntimeError(f\"{bot} not found in adapter {self.get_name()}\")\n        self.driver._bot_disconnect(bot)\n\n    def setup_http_server(self, setup: HTTPServerSetup):\n        \"\"\"\u8bbe\u7f6e\u4e00\u4e2a HTTP \u670d\u52a1\u5668\u8def\u7531\u914d\u7f6e\"\"\"\n        if not isinstance(self.driver, ReverseDriver):\n            raise TypeError(\"Current driver does not support http server\")\n        self.driver.setup_http_server(setup)\n\n    def setup_websocket_server(self, setup: WebSocketServerSetup):\n        \"\"\"\u8bbe\u7f6e\u4e00\u4e2a WebSocket \u670d\u52a1\u5668\u8def\u7531\u914d\u7f6e\"\"\"\n        if not isinstance(self.driver, ReverseDriver):\n            raise TypeError(\"Current driver does not support websocket server\")\n        self.driver.setup_websocket_server(setup)\n\n    async def request(self, setup: Request) -> Response:\n        \"\"\"\u8fdb\u884c\u4e00\u4e2a HTTP \u5ba2\u6237\u7aef\u8bf7\u6c42\"\"\"\n        if not isinstance(self.driver, ForwardDriver):\n            raise TypeError(\"Current driver does not support http client\")\n        return await self.driver.request(setup)\n\n    @asynccontextmanager\n    async def websocket(self, setup: Request) -> AsyncGenerator[WebSocket, None]:\n        \"\"\"\u5efa\u7acb\u4e00\u4e2a WebSocket \u5ba2\u6237\u7aef\u8fde\u63a5\u8bf7\u6c42\"\"\"\n        if not isinstance(self.driver, ForwardDriver):\n            raise TypeError(\"Current driver does not support websocket client\")\n        async with self.driver.websocket(setup) as ws:\n            yield ws\n\n    @abc.abstractmethod\n    async def _call_api(self, bot: Bot, api: str, **data: Any) -> Any:\n        \"\"\"`Adapter` \u5b9e\u9645\u8c03\u7528 api \u7684\u903b\u8f91\u5b9e\u73b0\u51fd\u6570\uff0c\u5b9e\u73b0\u8be5\u65b9\u6cd5\u4ee5\u8c03\u7528 api\u3002\n\n        \u53c2\u6570:\n            api: API \u540d\u79f0\n            data: API \u6570\u636e\n        \"\"\"\n        raise NotImplementedError\n\n\n__autodoc__ = {\"Adapter._call_api\": True}\n", "path": "nonebot/internal/adapter/adapter.py"}]}