From 0ba9eeb6a1818e7a246932e42f4db5d721310e89 Mon Sep 17 00:00:00 2001 From: tsxc Date: Thu, 6 Feb 2025 12:33:07 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E4=BD=A0=E7=9F=A5=E9=81=93?= =?UTF-8?q?=E5=90=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tips.yaml | 5 +++++ libraries/header.xaml | 3 ++- requirements.txt | 3 ++- script.py | 13 +++++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 Tips.yaml diff --git a/Tips.yaml b/Tips.yaml new file mode 100644 index 0000000..caad812 --- /dev/null +++ b/Tips.yaml @@ -0,0 +1,5 @@ +"Tips": + - "你知道吗:加载器的发行代号其实是绵中的各个楼以正大门为原点从近到远排的" + - "热知识:boen的饼一般会在三年内完成" + - "热知识:boen负责画饼,烙饼负责烙……" + - "😨知识:烙饼说他想让全服的人只能用加载器进服" \ No newline at end of file diff --git a/libraries/header.xaml b/libraries/header.xaml index 93fbc0a..b4994f6 100644 --- a/libraries/header.xaml +++ b/libraries/header.xaml @@ -1,3 +1,4 @@ + @@ -26,4 +27,4 @@ - \ No newline at end of file + diff --git a/requirements.txt b/requirements.txt index 5f8f6f0..eabf2a8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ datetime requests markdownify -python-dateutil \ No newline at end of file +python-dateutil +pyyaml \ No newline at end of file diff --git a/script.py b/script.py index 47a975d..567d07b 100644 --- a/script.py +++ b/script.py @@ -4,6 +4,8 @@ import xml.etree.ElementTree as ET from dateutil.parser import parse from markdownify import markdownify as md import os +import random +import yaml response = requests.get("https://mc.boen.fun/feed",verify=False) # os.open("feed.xml",os.O_CREAT) @@ -68,7 +70,18 @@ for child in root: os.system("mkdir public") os.system("builder build --output-path public/output.xaml") +# 将卡片设置为折叠 with open("public/output.xaml","r",encoding='UTF-8') as f: Text=f.read().replace("IsSwaped=\"False\"","IsSwaped=\"True\"") +with open("public/output.xaml","w",encoding='UTF-8') as f: + f.write(Text) + +# 随机添加一条你知道吗 +with open("Tips.yaml","r",encoding='UTF-8') as f: + Tips=yaml.load(f.read(),Loader=yaml.FullLoader)["Tips"] +Tip=Tips[random.SystemRandom().randint(0,len(Tips)-1)] + +with open("public/output.xaml","r",encoding='UTF-8') as f: + Text=f.read().replace("$你知道吗$",Tip) with open("public/output.xaml","w",encoding='UTF-8') as f: f.write(Text) \ No newline at end of file