summaryrefslogtreecommitdiff
path: root/ATRI/plugins/wife/data_source.py
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2021-07-08 22:09:00 +0800
committerKyomotoi <[email protected]>2021-07-08 22:09:00 +0800
commitbe2747e4d4b820ca0f1f988d3b77a628da26fe7b (patch)
treee1a59dd79ecd973a7d704568dcdc018f1f1b651a /ATRI/plugins/wife/data_source.py
parenta4e1b9d1581d756ef79ad063d1c0bd6b2fd13c1d (diff)
downloadATRI-be2747e4d4b820ca0f1f988d3b77a628da26fe7b.tar.gz
ATRI-be2747e4d4b820ca0f1f988d3b77a628da26fe7b.tar.bz2
ATRI-be2747e4d4b820ca0f1f988d3b77a628da26fe7b.zip
🔖♻️🐛🔧🔥📝 更新版本:YHN-001-A03
🔖 更新版本至:YHN-001-A03 ✨ 新增插件: - 涩图 - 闲聊(文爱 ♻️ 重构: - Service - 所有插件 🐛 修复部分小bug 🔧 暂时移除部分设置 🔥 删除: - 插件:nsfw、wife。日后加回 - 插件 essential 中部分内容 📝 更新README
Diffstat (limited to 'ATRI/plugins/wife/data_source.py')
-rw-r--r--ATRI/plugins/wife/data_source.py87
1 files changed, 0 insertions, 87 deletions
diff --git a/ATRI/plugins/wife/data_source.py b/ATRI/plugins/wife/data_source.py
deleted file mode 100644
index 9665351..0000000
--- a/ATRI/plugins/wife/data_source.py
+++ /dev/null
@@ -1,87 +0,0 @@
-import os
-import json
-from pathlib import Path
-
-
-WIFE_DIR = Path(".") / "ATRI" / "data" / "database" / "wife"
-MERRY_LIST_PATH = WIFE_DIR / "merry_list.json"
-os.makedirs(WIFE_DIR, exist_ok=True)
-
-
-class Tsuma:
- @staticmethod
- def _load_tsuma() -> dict:
- try:
- return json.loads(MERRY_LIST_PATH.read_bytes())
- except FileNotFoundError:
- with open(MERRY_LIST_PATH, "w") as r:
- r.write(json.dumps({}, indent=4))
- return dict()
-
- @staticmethod
- def _store_tsuma(data: dict) -> None:
- with open(MERRY_LIST_PATH, "w") as r:
- r.write(json.dumps(data, indent=4))
-
- @classmethod
- def check_tsuma(cls, user: str):
- data = cls._load_tsuma()
- if user in data:
- msg = "阿,你已经有老婆惹!" f"ta是:{data[user]['lassie']['nickname']}"
- return msg, True
- else:
- return "悲——你还没老婆...", False
-
- @classmethod
- def inquire_tsuma(cls, user: str) -> str:
- data = cls._load_tsuma()
- if user in data:
- return f"你的老婆是:{data[user]['lassie']['nickname']} 哦~❤"
- else:
- return "悲——你还没老婆..."
-
- @classmethod
- def got_tsuma(cls, user: str, d: dict) -> str:
- check_repo, if_h = cls.check_tsuma(user) # 防止出现多人同时操作导致 NTR 事件
- if if_h:
- return check_repo
- else:
- data = cls._load_tsuma()
- data[user] = {
- "nickname": d["nickname"],
- "gender": d["gender"],
- "lassie": {
- "nickname": d["lassie"]["nickname"],
- "qq": d["lassie"]["qq"],
- "gender": d["lassie"]["gender"],
- },
- }
- cls._store_tsuma(data)
-
- data[d["lassie"]["qq"]] = {
- "nickname": d["lassie"]["nickname"],
- "gender": d["lassie"]["gender"],
- "lassie": {
- "nickname": d["nickname"],
- "qq": user,
- "gender": d["gender"],
- },
- }
- cls._store_tsuma(data)
-
- msg = (
- f"> {d['lassie']['nickname']}({d['lassie']['qq']})\n"
- f"恭喜成为 {d['nickname']} 的老婆~⭐"
- )
- return msg
-
- @classmethod
- def divorce(cls, user: str) -> str:
- data = cls._load_tsuma()
- if not user in data:
- return "悲——你还没老婆。。"
-
- msg = f"悲——,({data[user]['nickname']})抛弃了({data[user]['lassie']['nickname']})"
- del data[user]
- cls._store_tsuma(data)
- return msg