We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Bug: 内置的single_session插件有一些bug
**描述问题：**

内置的`single_session`插件只能处理有`get_session_id`方法的`event`，如果一个`matcher`监听了`metaevent`，那么其中的`run_preprocessor`会报错

**如何复现？**

[这一行](https://github.com/nonebot/nonebot2/blob/93ffc93a80cf9e3103eb4a164e7b32ab3cdd0882/nonebot/plugins/single_session.py#L13)限制了只能监听有`get_session_id`的事件，但是对没有这个方法的事件没有做额外的处理，导致报错。
除此之外，下面的[判断语句](https://github.com/nonebot/nonebot2/blob/93ffc93a80cf9e3103eb4a164e7b32ab3cdd0882/nonebot/plugins/single_session.py#L16)也有问题，如果这个事件第一次遇到的话不应该被忽略

**期望的结果**
插件正常使用

````


--- 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/plugins/single_session.py`
Content:
```
1 from typing import Dict, Optional
2 
3 from nonebot.typing import T_State
4 from nonebot.matcher import Matcher
5 from nonebot.adapters import Bot, Event
6 from nonebot.message import run_preprocessor, run_postprocessor, IgnoredException
7 
8 _running_matcher: Dict[str, int] = {}
9 
10 
11 @run_preprocessor
12 async def _(matcher: Matcher, bot: Bot, event: Event, state: T_State):
13     session_id = event.get_session_id()
14     event_id = id(event)
15 
16     if _running_matcher.get(session_id, None) != event_id:
17         raise IgnoredException("Annother matcher running")
18 
19     _running_matcher[session_id] = event_id
20 
21 
22 @run_postprocessor
23 async def _(matcher: Matcher, exception: Optional[Exception], bot: Bot, event: Event, state: T_State):
24     session_id = event.get_session_id()
25     if session_id in _running_matcher:
26         del _running_matcher[session_id]
27
```
--- 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()

```

diff --git a/nonebot/plugins/single_session.py b/nonebot/plugins/single_session.py
--- a/nonebot/plugins/single_session.py
+++ b/nonebot/plugins/single_session.py
@@ -10,17 +10,23 @@
 
 @run_preprocessor
 async def _(matcher: Matcher, bot: Bot, event: Event, state: T_State):
-    session_id = event.get_session_id()
-    event_id = id(event)
-
-    if _running_matcher.get(session_id, None) != event_id:
+    try:
+        session_id = event.get_session_id()
+    except Exception:
+        return
+    current_event_id = id(event)
+    event_id = _running_matcher.get(session_id, None)
+    if event_id and event_id != current_event_id:
         raise IgnoredException("Annother matcher running")
 
-    _running_matcher[session_id] = event_id
+    _running_matcher[session_id] = current_event_id
 
 
 @run_postprocessor
 async def _(matcher: Matcher, exception: Optional[Exception], bot: Bot, event: Event, state: T_State):
-    session_id = event.get_session_id()
+    try:
+        session_id = event.get_session_id()
+    except Exception:
+        return
     if session_id in _running_matcher:
         del _running_matcher[session_id]

{"golden_diff": "diff --git a/nonebot/plugins/single_session.py b/nonebot/plugins/single_session.py\n--- a/nonebot/plugins/single_session.py\n+++ b/nonebot/plugins/single_session.py\n@@ -10,17 +10,23 @@\n \n @run_preprocessor\n async def _(matcher: Matcher, bot: Bot, event: Event, state: T_State):\n-    session_id = event.get_session_id()\n-    event_id = id(event)\n-\n-    if _running_matcher.get(session_id, None) != event_id:\n+    try:\n+        session_id = event.get_session_id()\n+    except Exception:\n+        return\n+    current_event_id = id(event)\n+    event_id = _running_matcher.get(session_id, None)\n+    if event_id and event_id != current_event_id:\n         raise IgnoredException(\"Annother matcher running\")\n \n-    _running_matcher[session_id] = event_id\n+    _running_matcher[session_id] = current_event_id\n \n \n @run_postprocessor\n async def _(matcher: Matcher, exception: Optional[Exception], bot: Bot, event: Event, state: T_State):\n-    session_id = event.get_session_id()\n+    try:\n+        session_id = event.get_session_id()\n+    except Exception:\n+        return\n     if session_id in _running_matcher:\n         del _running_matcher[session_id]\n", "issue": "Bug: \u5185\u7f6e\u7684single_session\u63d2\u4ef6\u6709\u4e00\u4e9bbug\n**\u63cf\u8ff0\u95ee\u9898\uff1a**\r\n\r\n\u5185\u7f6e\u7684`single_session`\u63d2\u4ef6\u53ea\u80fd\u5904\u7406\u6709`get_session_id`\u65b9\u6cd5\u7684`event`\uff0c\u5982\u679c\u4e00\u4e2a`matcher`\u76d1\u542c\u4e86`metaevent`\uff0c\u90a3\u4e48\u5176\u4e2d\u7684`run_preprocessor`\u4f1a\u62a5\u9519\r\n\r\n**\u5982\u4f55\u590d\u73b0\uff1f**\r\n\r\n[\u8fd9\u4e00\u884c](https://github.com/nonebot/nonebot2/blob/93ffc93a80cf9e3103eb4a164e7b32ab3cdd0882/nonebot/plugins/single_session.py#L13)\u9650\u5236\u4e86\u53ea\u80fd\u76d1\u542c\u6709`get_session_id`\u7684\u4e8b\u4ef6\uff0c\u4f46\u662f\u5bf9\u6ca1\u6709\u8fd9\u4e2a\u65b9\u6cd5\u7684\u4e8b\u4ef6\u6ca1\u6709\u505a\u989d\u5916\u7684\u5904\u7406\uff0c\u5bfc\u81f4\u62a5\u9519\u3002\r\n\u9664\u6b64\u4e4b\u5916\uff0c\u4e0b\u9762\u7684[\u5224\u65ad\u8bed\u53e5](https://github.com/nonebot/nonebot2/blob/93ffc93a80cf9e3103eb4a164e7b32ab3cdd0882/nonebot/plugins/single_session.py#L16)\u4e5f\u6709\u95ee\u9898\uff0c\u5982\u679c\u8fd9\u4e2a\u4e8b\u4ef6\u7b2c\u4e00\u6b21\u9047\u5230\u7684\u8bdd\u4e0d\u5e94\u8be5\u88ab\u5ffd\u7565\r\n\r\n**\u671f\u671b\u7684\u7ed3\u679c**\r\n\u63d2\u4ef6\u6b63\u5e38\u4f7f\u7528\r\n\r\n````\r\n\n", "before_files": [{"content": "from typing import Dict, Optional\n\nfrom nonebot.typing import T_State\nfrom nonebot.matcher import Matcher\nfrom nonebot.adapters import Bot, Event\nfrom nonebot.message import run_preprocessor, run_postprocessor, IgnoredException\n\n_running_matcher: Dict[str, int] = {}\n\n\n@run_preprocessor\nasync def _(matcher: Matcher, bot: Bot, event: Event, state: T_State):\n    session_id = event.get_session_id()\n    event_id = id(event)\n\n    if _running_matcher.get(session_id, None) != event_id:\n        raise IgnoredException(\"Annother matcher running\")\n\n    _running_matcher[session_id] = event_id\n\n\n@run_postprocessor\nasync def _(matcher: Matcher, exception: Optional[Exception], bot: Bot, event: Event, state: T_State):\n    session_id = event.get_session_id()\n    if session_id in _running_matcher:\n        del _running_matcher[session_id]\n", "path": "nonebot/plugins/single_session.py"}], "after_files": [{"content": "from typing import Dict, Optional\n\nfrom nonebot.typing import T_State\nfrom nonebot.matcher import Matcher\nfrom nonebot.adapters import Bot, Event\nfrom nonebot.message import run_preprocessor, run_postprocessor, IgnoredException\n\n_running_matcher: Dict[str, int] = {}\n\n\n@run_preprocessor\nasync def _(matcher: Matcher, bot: Bot, event: Event, state: T_State):\n    try:\n        session_id = event.get_session_id()\n    except Exception:\n        return\n    current_event_id = id(event)\n    event_id = _running_matcher.get(session_id, None)\n    if event_id and event_id != current_event_id:\n        raise IgnoredException(\"Annother matcher running\")\n\n    _running_matcher[session_id] = current_event_id\n\n\n@run_postprocessor\nasync def _(matcher: Matcher, exception: Optional[Exception], bot: Bot, event: Event, state: T_State):\n    try:\n        session_id = event.get_session_id()\n    except Exception:\n        return\n    if session_id in _running_matcher:\n        del _running_matcher[session_id]\n", "path": "nonebot/plugins/single_session.py"}]}