From 98ffd6c03c9e2b5368f31b4b29679993064f9079 Mon Sep 17 00:00:00 2001 From: SuperSonic Date: Fri, 7 Feb 2020 20:35:26 +0800 Subject: [PATCH] Fix some bug of mds --- README.md | 8 ++++++-- libs/data_mds.py | 41 ++++++++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index cfe93f5..7290c84 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Star Yuuki(pYthon) BOT - Yuuki ![Scrutinizer-CI_Build](https://scrutinizer-ci.com/g/star-inc/star_yuuki_bot/badges/build.png?b=rolling) ![Scrutinizer-CI_Quality](https://scrutinizer-ci.com/g/star-inc/star_yuuki_bot/badges/quality-score.png?b=rolling) ![Code-Inspector_Score](https://www.code-inspector.com/project/3632/score/svg) ![Code-Inspector_Score](https://www.code-inspector.com/project/3632/status/svg) -A Python BOT for LINE Group Protection with LINE Unofficial API. +A Python BOT for LINE Group Protection. ![ICON](logo.png) ## Maybe you had seen it ! @@ -34,7 +34,9 @@ Recommend Environment: pip install -Ur requirements.txt ## Usage -+ Configure your connection in `main.py` ++ Copy `config.yaml` from `config.sample.yaml` + ++ Configure your settings and environment in `config.yaml` + Exec: @@ -46,3 +48,5 @@ Maybe you want the source of history version. Click [it](https://github.com/star ### Logo Copyright Copyright of the Image which was named "logo.png" belongs to "[©川原 礫/ASCII Media Works/SAO Project](https://www.aniplex.co.jp)". + +> (c) 2020 Star Inc. \ No newline at end of file diff --git a/libs/data_mds.py b/libs/data_mds.py index 68c4d30..e6381ef 100644 --- a/libs/data_mds.py +++ b/libs/data_mds.py @@ -5,7 +5,7 @@ To switch data in multiprocessing. LICENSE: MPL 2.0 - (c)2019 Star Inc. + (c)2020 Star Inc. """ # Initializing @@ -20,36 +20,38 @@ auth_code = 0 # Functions -def mds_exit(): - exit(0) +def mds_exit(data): + if data: + exit(0) -def update(path, data): +def update(data): global switch_data try: - if type(path) is list: - over = query(path) - over.get("data").update(data) + if type(data["path"]) is list: + over = query({"path": data["path"]}) + over.get("data").update(data["data"]) return {"status": 200} return {"status": 400} except: return {"status": 500} -def delete(path, data): +def delete(data): global switch_data try: - if type(path) is list: - over = query(path) - over.get("data").pop(data) + if type(data["path"]) is list: + over = query({"path": data["path"]}) + over.get("data").pop(data["data"]) return {"status": 200} return {"status": 400} except: return {"status": 500} -def query(query_data): +def query(data): global switch_data + query_data = data["path"] try: if type(switch_data) is dict and type(query_data) is list: result = switch_data @@ -71,19 +73,19 @@ def query(query_data): return {"status": 500} -def sync(path): +def sync(data): global switch_data try: - switch_data = path + switch_data = data["path"] return {"status": 200} except: return {"status": 500} -def yuukiLimitDecrease(path, userId): +def yuukiLimitDecrease(data): global switch_data try: - switch_data["LimitInfo"][path][userId] -= 1 + switch_data["LimitInfo"][data["path"]][data["userId"]] -= 1 return {"status": 200} except: return {"status": 500} @@ -114,7 +116,12 @@ class IndexHandler(RequestHandler): req_str = req_body.decode('utf8') req_res = json.loads(req_str) if req_res.get("code") == auth_code: - result = _work[req_res.get("do")](req_res.get("path"), req_res.get("data")) + result = _work[req_res.get("do")]( + { + "path":req_res.get("path"), + "data":req_res.get("data") + } + ) else: result = {"status": 401} if not result: