diff options
author | Kyomotoi <[email protected]> | 2021-07-31 16:16:47 +0800 |
---|---|---|
committer | Kyomotoi <[email protected]> | 2021-07-31 16:16:47 +0800 |
commit | 336eb9d9e98b0bee952c27a50820dbdb350bcc03 (patch) | |
tree | 718d5349232bce0d06cc901707bdd8f478c43314 /ATRI/plugins/wife/data_source.py | |
parent | c485985d3be687d17168512de44ea7b744fea7cc (diff) | |
download | ATRI-336eb9d9e98b0bee952c27a50820dbdb350bcc03.tar.gz ATRI-336eb9d9e98b0bee952c27a50820dbdb350bcc03.tar.bz2 ATRI-336eb9d9e98b0bee952c27a50820dbdb350bcc03.zip |
🔥🚚✨
- 移除:laugh.txt,需要时再拉取
- 移动控制台文件至plugins/console目录下
- 新增:
- 和管理贴贴w
- 正式的可视化前端单页
Diffstat (limited to 'ATRI/plugins/wife/data_source.py')
-rw-r--r-- | ATRI/plugins/wife/data_source.py | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/ATRI/plugins/wife/data_source.py b/ATRI/plugins/wife/data_source.py new file mode 100644 index 0000000..38e8be4 --- /dev/null +++ b/ATRI/plugins/wife/data_source.py @@ -0,0 +1,68 @@ +import os +import json +from random import choice +from pathlib import Path +from nonebot.adapters.cqhttp import MessageSegment + +from ATRI.service import Service +from ATRI.rule import is_in_service + + +WIFE_DIR = Path(".") / "data" / "database" / "wife" +os.makedirs(WIFE_DIR, exist_ok=True) + + +__doc__ = """ +老婆...嘿嘿嘿... +""" + + +class Wife(Service): + + def __init__(self): + Service.__init__(self, "老婆", __doc__, rule=is_in_service("老婆")) + + def to_superuser(self, user_id: str): + """ + 全自动贴贴机,限制只有超级管理员才能贴贴 + """ + content = choice( + [ + "mua!", + "贴贴!", + MessageSegment.image(file="https://cdn.jsdelivr.net/gh/Kyomotoi/CDN@master/project/ATRI/wife0.jpg"), + MessageSegment.image(file="https://cdn.jsdelivr.net/gh/Kyomotoi/CDN@master/project/ATRI/wife1.jpg"), + MessageSegment.image(file="https://cdn.jsdelivr.net/gh/Kyomotoi/CDN@master/project/ATRI/wife2.jpg"), + MessageSegment.image(file="https://cdn.jsdelivr.net/gh/Kyomotoi/CDN@master/project/ATRI/wife3.jpg") + ] + ) + result = MessageSegment.at(user_id) + content + return result + + @staticmethod + def load_marry_list() -> dict: + """ + 读取结婚列表 + """ + file_name = "marry_list.json" + path = WIFE_DIR / file_name + if not path.is_file(): + with open(path, "w", encoding="utf-8") as w: + w.write(json.dumps({})) + + data = json.loads(path.read_bytes()) + return data + + @staticmethod + def save_marry_list(data: dict) -> None: + """ + 存储结婚列表 + """ + file_name = "marry_list.json" + path = WIFE_DIR / file_name + if not path.is_file(): + with open(path, "w", encoding="utf-8") as w: + w.write(json.dumps({})) + + with open(path, "w", encoding="utf-8") as w: + w.write(json.dumps(data, indent=4)) |