diff options
author | Kyomotoi <kyomotoiowo@gmail.com> | 2022-05-04 16:07:18 +0800 |
---|---|---|
committer | Kyomotoi <kyomotoiowo@gmail.com> | 2022-05-04 16:07:18 +0800 |
commit | 7042d94213532191a0c72d34d7c85193184c079f (patch) | |
tree | 0ec3c458f828889f92719e7010bf0a031a627de7 /ATRI/plugins/status/driver/view.py | |
parent | 18302364230e5f7898b3c2da56284e89d86d1947 (diff) | |
download | ATRI-7042d94213532191a0c72d34d7c85193184c079f.tar.gz ATRI-7042d94213532191a0c72d34d7c85193184c079f.tar.bz2 ATRI-7042d94213532191a0c72d34d7c85193184c079f.zip |
✨ 为前端页面打基础, 更新命令及API
Diffstat (limited to 'ATRI/plugins/status/driver/view.py')
-rw-r--r-- | ATRI/plugins/status/driver/view.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/ATRI/plugins/status/driver/view.py b/ATRI/plugins/status/driver/view.py new file mode 100644 index 0000000..5d8c56f --- /dev/null +++ b/ATRI/plugins/status/driver/view.py @@ -0,0 +1,39 @@ +from ..data_source import Status +from ..listener import get_message_deal_info + + +def handle_base_uri(): + return {"status": 204, "msg": "This path just for console load."} + + +def handle_runtime_info(token: str): + auth, data = auth_token(token) + plat, bot = Status().get_status(True) + if auth: + return {"status": 200, "data": {"platform": plat, "bot": bot}} + else: + return data + + +def handle_message_deal_info(token: str): + auth, data = auth_token(token) + if auth: + return {"status": 200, "data": get_message_deal_info()} + else: + return data + + +def handle_auther(token: str): + auth, data = auth_token(token) + return data if auth else data + + +def auth_token(token: str) -> tuple: + auth_data: dict = Status().get_auth_info() + if not auth_data.get("token", None): + return False, {"status": 500, "msg": "This bot is not create auth data yet."} + _token = auth_data["token"] + if token != _token: + return False, {"status": 403, "msg": "Token error, please check again."} + else: + return True, {"status": 200, "msg": "OK"} |