summaryrefslogtreecommitdiff
path: root/ATRI/plugins/manage/modules/shutdown.py
blob: 78f23e8c194e0301b1ad37e05d0c4cc42ed513d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from nonebot.typing import T_State
from nonebot.permission import SUPERUSER
from nonebot.adapters.cqhttp import Bot, MessageEvent

from ATRI.service import Service as sv


__doc__ = """
紧急停机
权限组:维护者
用法:
  @ 关机
"""

shutdown = sv.on_command(cmd="关机", docs=__doc__, permission=SUPERUSER)


@shutdown.handle()
async def _shutdown(bot: Bot, event: MessageEvent, state: T_State) -> None:
    msg = str(event.message).strip()
    if msg:
        state["msg"] = msg


@shutdown.got("msg", prompt="[WARNING]此项操作将强行终止bot运行,是否继续(y/n)")
async def __shutdown(bot: Bot, event: MessageEvent, state: T_State) -> None:
    t = ["y", "Y", "是"]
    if state["msg"] in t:
        await bot.send(event, "咱还会醒来的,一定")
        exit(0)
    else:
        await shutdown.finish("再考虑下吧 ;w;")