From 799cc2110b608a47de416033dd3f7953b4f6d72f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=8A=E6=99=9A=E6=89=93=E8=80=81=E8=99=8E?= Date: Fri, 3 Apr 2026 23:12:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=E6=8A=95=E7=A8=BF]=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=84=9A=E6=9C=AC:=20=E6=AF=8F=E6=97=A5=E5=90=8D=E8=A8=80=20?= =?UTF-8?q?=E2=80=94=20by=20Silence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scripts/widgets/script_mnj1lj72.py | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 script_library/scripts/widgets/script_mnj1lj72.py diff --git a/script_library/scripts/widgets/script_mnj1lj72.py b/script_library/scripts/widgets/script_mnj1lj72.py new file mode 100644 index 0000000..f3bdfda --- /dev/null +++ b/script_library/scripts/widgets/script_mnj1lj72.py @@ -0,0 +1,93 @@ + +# 2026-4-3 Silence + +import requests +from widget import Widget, family, MEDIUM + +BLACKLIST = ["死", "杀", "恨", "怨", "哭", "泪", "痛", "苦", "穷", + "失败", "绝望", "黑暗", "孤独", "放弃", "离开", "背叛", + "悲伤", "痛苦", "哭泣", "受伤", "残忍", "抑郁", "焦虑", "堕落"] + +def is_good(text): + for w in BLACKLIST: + if w in text: + return False + return True + +def get_motto(): + categories = ['d', 'i', 'k'] + for _ in range(8): + try: + import random + cat = random.choice(categories) + url = f"https://v1.hitokoto.cn/?c={cat}" + resp = requests.get(url, timeout=5) + if resp.status_code == 200: + data = resp.json() + text = data.get('hitokoto', '') + if not text or len(text) < 8 or len(text) > 24: + continue + if not is_good(text): + continue + from_who = data.get('from_who', '') + from_where = data.get('from', '') + if from_who and from_where: + if from_who in from_where or from_where in from_who: + author = from_who if from_who else from_where + else: + author = f"{from_who} · {from_where}" + elif from_who: + author = from_who + elif from_where: + author = from_where + else: + author = "" + return text, author + except: + pass + return "每天进步一点点,坚持带来大改变。", "佚名" + +def render_widget(): + quote, author = get_motto() + if len(quote) > 22: + quote = quote[:20] + "…" + + bg_color = ("#FEFCE8", "#1E1A2F") + w = Widget(background=bg_color, padding=16) + + with w.vstack(spacing=10): + with w.hstack(): + w.icon("heart.text.square.fill", size=18, color="#E63946") + w.text("每日名言", size=14, weight="semibold", color=("#1E293B", "#E2E8F0")) + w.spacer() + w.icon("leaf.fill", size=12, color="#A3E635") + + w.divider(color=("#E2E8F0", "#334155")) + + with w.hstack(): + w.icon("quote.opening", size=14, color=("#94A3B8", "#64748B")) + w.spacer(4) + w.spacer(4) + + w.text(f"「{quote}」", size=15, weight="medium", + color=("#0F172A", "#F1F5F9"), align="left", max_lines=3) + + w.spacer(4) + + if author: + w.text(f"—— {author}", size=11, color=("#64748B", "#94A3B8"), + align="right", max_lines=1) + else: + w.text(" 给今天一点力量 ", size=10, color=("#94A3B8", "#6B7280"), align="center") + + w.render() + +if family == MEDIUM: + render_widget() +else: + w = Widget(background=("#FFFFFF", "#0B0F1A"), padding=16) + with w.vstack(align="center", spacing=8): + w.icon("heart.text.square", size=30, color="#E63946") + w.text("请使用中尺寸小组件", size=14, weight="semibold", + color=("#111", "#EEE"), align="center") + w.render() \ No newline at end of file From 6d077b8cdcb72b53286d19299dbbd77bc4c9e502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=8A=E6=99=9A=E6=89=93=E8=80=81=E8=99=8E?= Date: Fri, 3 Apr 2026 23:12:31 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[=E6=8A=95=E7=A8=BF]=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=20index.json:=20=E6=B7=BB=E5=8A=A0=20=E6=AF=8F=E6=97=A5?= =?UTF-8?q?=E5=90=8D=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script_library/index.json | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/script_library/index.json b/script_library/index.json index edd9aec..7ab5ad9 100644 --- a/script_library/index.json +++ b/script_library/index.json @@ -1,7 +1,7 @@ { "format_version": 1, - "data_version": 65, - "updated": "2026-04-03T10:40:27.436Z", + "data_version": 66, + "updated": "2026-04-03T15:12:30.481Z", "announcement": null, "categories": [ { @@ -1282,6 +1282,29 @@ "updated": null, "status": "active", "lines": 93 + }, + { + "id": "script_mnj1lj72", + "name": "每日名言", + "name_en": "每日名言", + "desc": "每日名言,仅仅支持中组件", + "desc_en": "每日名言,仅仅支持中组件", + "category": "widgets", + "file": "scripts/widgets/script_mnj1lj72.py", + "thumbnail": null, + "version": 1, + "file_type": "py", + "author": "Silence", + "author_en": "Silence", + "tags": [ + "community" + ], + "requires": [], + "min_app_version": "1.5.0", + "added": "2026-04-03", + "updated": null, + "status": "active", + "lines": 93 } ] }