Adjust kill_current_session() function

This commit is contained in:
Richard Chien 2018-12-27 20:33:28 +08:00
parent 663797219a
commit a2469b45f4
2 changed files with 3 additions and 5 deletions

View File

@ -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` 中强行移除当前正在运行的会话。

View File

@ -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)