mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-27 18:45:05 +08:00
Adjust kill_current_session() function
This commit is contained in:
parent
663797219a
commit
a2469b45f4
@ -1478,7 +1478,7 @@ sidebar: auto
|
||||
|
||||
从内部调用 `say` 命令,且不检查权限。
|
||||
|
||||
### `kill_current_session(bot, ctx)`
|
||||
### `kill_current_session(ctx)`
|
||||
|
||||
- **说明:**
|
||||
|
||||
@ -1486,7 +1486,6 @@ sidebar: auto
|
||||
|
||||
- **参数:**
|
||||
|
||||
- `bot: NoneBot`: NoneBot 对象
|
||||
- `ctx: Context_T`: 事件上下文对象
|
||||
|
||||
- **返回:**
|
||||
@ -1498,7 +1497,7 @@ sidebar: auto
|
||||
```python
|
||||
@on_command('kill', privileged=True)
|
||||
async def _(session: CommandSession):
|
||||
kill_current_session(session.bot, session.ctx)
|
||||
kill_current_session(session.ctx)
|
||||
```
|
||||
|
||||
在特权命令 `kill` 中强行移除当前正在运行的会话。
|
||||
|
@ -603,12 +603,11 @@ async def _real_run_command(session: CommandSession,
|
||||
raise e # this is intended to be propagated to handle_message()
|
||||
|
||||
|
||||
def kill_current_session(bot: NoneBot, ctx: Context_T) -> None:
|
||||
def kill_current_session(ctx: Context_T) -> None:
|
||||
"""
|
||||
Force kill current session of the given context,
|
||||
despite whether it is running or not.
|
||||
|
||||
:param bot: NoneBot instance
|
||||
:param ctx: message context
|
||||
"""
|
||||
ctx_id = context_id(ctx)
|
||||
|
Loading…
Reference in New Issue
Block a user