吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 9879|回复: 374
上一主题 下一主题
收起左侧

[Python 原创] 我宣布了自己死亡--github生命监测

    [复制链接]
跳转到指定楼层
楼主
jockon 发表于 2026-11-3 18:06 回帖奖励
本帖最后由 jockon 于 2026-11-4 06:44 编辑

前一段时间死了么app火了一阵,没想到这么快我就要用上了。作者也得了绝症,也将不久人世,再见了~(无需过问)

自己简单搓了一个非app的,使用github action每天更新状态,action workflow可手动签到或死亡,死亡后自动更新README.md在自己的主页上。

[b]存活判定方式:

  1. workflow 手动签到;
  2. 任务每天执行,7天内没签到默认存活;

[b]死亡判定方式:

1.超过7天未手动签到即宣布死亡。
2.手动执行 workflow 立即死亡。

死亡后:
更新首页README,宣布死亡消息(没了)。

因每个人的信息不同,需要修改成自己的,项目名用自己的用户名(这样可以显示在自己主页上)

https://github.com/Zhu-junwei/Zhu-junwei/

自动任务 life-monitor.yml

name: Life Monitor

on:
  schedule:
    - cron: '00 19 * * *'
  workflow_dispatch:
    inputs:
      mode:
        description: '选择运行模式'
        required: true
        type: choice
        options:
          - 签到
          - 死亡

jobs:
  monitor:
    runs-on: ubuntu-24.04
    permissions:
      contents: write

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Setup Python
        uses: actions/setup-python@v7.1.0
        with:
          python-version: '3.13'

      - name: Run life monitor
        run: |
          MODE="${{ github.event.inputs.mode }}"
          if [ "$MODE" = "签到" ]; then
            python life_monitor.py
          elif [ "$MODE" = "死亡" ]; then
            python life_monitor.py --force-death
          else
            # 定时触发:只检查不签到,超过7天自动宣告死亡
            python life_monitor.py --auto
          fi

      - name: Commit and push
        run: |
          MODE="${{ github.event.inputs.mode }}"
          MSG="${MODE:-自动签到}"
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add README.md .last_run
          git diff --cached --quiet || git commit -m "life monitor: $MSG"
          git push

死亡逻辑life_monitor.py

#!/usr/bin/env python3
"""生命监测系统"""

import os
import datetime

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATE_FILE = os.path.join(BASE_DIR, ".last_run")
README_PATH = os.path.join(BASE_DIR, "README.md")

MAX_DAYS = 7
BIRTH_DATE = datetime.date(1995, 4, 23)
BJ = datetime.timezone(datetime.timedelta(hours=8))

def read_last_run():
    if not os.path.exists(STATE_FILE):
        return None
    try:
        with open(STATE_FILE, "r", encoding="utf-8") as f:
            raw = f.read().strip()
        dt = datetime.datetime.fromisoformat(raw)
        if dt.tzinfo is None:
            dt = dt.replace(tzinfo=BJ)
        return dt
    except Exception:
        return None

def write_last_run(dt):
    with open(STATE_FILE, "w", encoding="utf-8") as f:
        f.write(dt.isoformat())

def now():
    return datetime.datetime.now(BJ)

def generate_alive_content(last_run, days, scan_time):
    lines = [
        f"🟢 上次存活时间: {last_run.strftime('%Y-%m-%d %H:%M:%S')} (UTC+8)",
        "",
        f"更新时间: {scan_time.strftime('%Y-%m-%d %H:%M:%S')} (UTC+8)",
    ]
    return "\n".join(lines)

def generate_obituary_content(last_run, days, scan_time, force_death=False):
    birth = BIRTH_DATE
    if force_death:
        # 手动确认死亡:死亡日期为当前扫描日期,保留真实最后存活时间
        death_date = scan_time.date()
        death_detail = ""
        death_reason = "手动确认死亡。"
        days_line = f"> **距上次执行**: {days} 天"
    else:
        # 自动判定死亡:超过阈值,估算死亡日期
        death_date = (last_run + datetime.timedelta(days=MAX_DAYS)).date()
        death_detail = f"(最后手动执行后第 {MAX_DAYS} 天(估算))"
        death_reason = f"超过 {MAX_DAYS} 天未检测到生命体征,按协议发布讣告。"
        days_line = f"> **距上次执行**: {days} 天"
    age = death_date.year - birth.year - ((death_date.month, death_date.day) < (birth.month, birth.day))

    with open(os.path.join(BASE_DIR, "obituary.md"), "r", encoding="utf-8") as f:
        content = f.read()

    replacements = {
        "{{BIRTH_DATE}}": birth.strftime('%Y-%m-%d'),
        "{{BIRTH_LUNAR}}": "农历一九九五年三月廿四",
        "{{NAME}}": "朱俊伟",
        "{{DEATH_DATE}}": death_date.strftime('%Y-%m-%d'),
        "{{AGE}}": str(age),
        "{{MAX_DAYS}}": str(MAX_DAYS),
        "{{LAST_RUN}}": last_run.strftime('%Y-%m-%d %H:%M:%S'),
        "{{SCAN_TIME}}": scan_time.strftime('%Y-%m-%d %H:%M:%S'),
        "{{DEATH_DETAIL}}": death_detail,
        "{{DEATH_REASON}}": death_reason,
        "{{DAYS_LINE}}": days_line,
    }

    for key, value in replacements.items():
        content = content.replace(key, value)

    return content

def run():
    import sys
    auto_mode = "--auto" in sys.argv
    force_death = "--force-death" in sys.argv

    scan_time = now()
    last_run = read_last_run()

    if force_death:
        # 死亡模式:不修改 .last_run,保留真实的上次存活时间
        # 如果没有历史记录,用当前时间兜底
        if last_run is None:
            last_run = scan_time
    elif not auto_mode:
        # 手动签到:更新 .last_run 为当前时间
        write_last_run(scan_time)
        last_run = scan_time

    if last_run is None:
        days = 0
        if force_death:
            # 没有历史记录但手动确认死亡
            content = generate_obituary_content(scan_time, days, scan_time, force_death)
        else:
            content = generate_alive_content(scan_time, days, scan_time)
    else:
        days = (scan_time - last_run).days
        if force_death:
            # 手动确认死亡:直接生成讣告,不经过阈值判断
            print(f"💀 手动确认死亡。最后存活时间: {last_run.strftime('%Y-%m-%d %H:%M:%S')}")
            content = generate_obituary_content(last_run, days, scan_time, force_death)
        elif days > MAX_DAYS:
            print(f"⚠️  距上次手动执行已过去 {days} 天,超过 {MAX_DAYS} 天阈值!")
            content = generate_obituary_content(last_run, days, scan_time, force_death)
        else:
            print(f"✅ 距上次手动执行 {days} 天,在 {MAX_DAYS} 天阈值内。")
            content = generate_alive_content(last_run, days, scan_time)

    with open(README_PATH, "w", encoding="utf-8") as f:
        f.write(content)

    print(f"📝 README.md 已更新")
    print(f"   间隔: {days} 天 | 模式: {'自动检查' if auto_mode else ('强制死亡' if force_death else '手动打卡')}")
    print(f"   状态: {'讣告' if last_run and days > MAX_DAYS else '正常'}")

if __name__ == "__main__":
    run()

免费评分

参与人数 184吾爱币 +197 热心值 +167 收起 理由
LOSTFOREVER + 1 加油!
Tomylove + 1 + 1 热心回复!
超薄苏菲透气爽 + 1 + 1 加油兄弟
slzray + 1 + 1 解脱了兄弟
ixinlin + 1 热心回复!
Reacher + 1 加油
ximing521 + 1 + 1 解脱了 未尝不是一种幸福
柒點 + 1 + 1 加油 兄弟~~
linjie716 + 1 + 1 谢谢@Thanks!
不夜传奇 + 1 + 1 加油!
aipiaoxu + 1 + 1 加油
苏落 + 1 + 1 加油&amp;amp;#128170;
Alexvictor + 1 + 1 谢谢@Thanks!
jiaxin9873 + 1 热心回复!
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
AceroJM + 1 + 1 加油
chic-vin + 1 + 1 加油~!!!
cayuer + 3 + 1 加油 兄弟
秋华 + 1 很少回复,一定是误判,一定会好起来!
44149966 + 1 + 1 加油!
post927 + 1 + 1 谢谢@Thanks!
可爱的典哒哒 + 1 + 1 加油!
xiaomr1990 + 1 + 1 谢谢@Thanks!
YFxbxb888 + 2 + 1 用心讨论,共获提升!
chensir01 + 1 + 1 我很赞同!
libibiao + 1 + 1 谢谢@Thanks!
su27_jx + 1 我很赞同!
lin5789 + 1 热心回复!
男shen + 1 + 1 兄弟 加油~!!!
Sound + 3 + 1 这条路虽然很难,但是你已经很勇敢了,加油~加油~加油~&amp;amp;#128591;
liujinlai + 1 赛博永生
开心熊猫741 + 1 + 1 活下去,兄弟
小怕i + 1 + 1 加油兄弟
Fullerene001 + 1 + 1 谢谢@Thanks!
ygh2000year + 1 + 1 兄弟,加油,希望你越来越好
缘浅丶 + 1 + 1 希望楼主可以天天开心!
工口人魔 + 1 + 1 加油!生命永不停止
sdzdp + 1 + 1 生命的意义何在?
myz930 + 1 + 1 加油啊 好好对待每寸光阴
happyoil001 + 1 + 1 生命是一场绚烂的烟火,玩得开心点
lgsloving + 1 + 1 谢谢@Thanks!
freedom3027 + 1 + 1 用自己喜欢的方式生活吧,加油兄弟
SFChiu + 1 + 1 加油啊,不要放弃!
熙lk + 1 + 1 用心讨论,共获提升!
流云削峰 + 1 + 1 加油,愿平安。。。
AiMoon123 + 1 + 1 热心回复!
枫叶之秋 + 1 + 1 我很赞同!
xz1689 + 1 + 1 加油!
lw12138 + 1 加油!也别放弃,万一呢
moon2022 + 1 + 1 加油!
goddness + 1 + 1 加油bro
kenanxwl + 1 兄弟,下辈子别来这了,去欧洲吧
hxz8998 + 1 + 1 很少回复,一定是误判,一定会好起来!
柚子不甜 + 1 + 1 我很赞同!
小小的 + 1 + 1 我很赞同!
crb8331 + 1 + 1 我很赞同!
william0712 + 2 + 1 人生充满希望,年纪轻轻的,这个世界还有好多地方没去过呢,说出来有可能大 ...
szzzzzzy + 1 + 1 谢谢@Thanks!
a526437928 + 1 + 1 谢谢@Thanks!
IcePlume + 1 + 1 我很赞同!
gofeel2024 + 1 + 1 加油
原来。 + 1 + 1 不到最后一刻,一切皆有可能!不要放弃。
飘舞凌乱 + 1 + 1 兄弟加油
niejiong88 + 1 我很赞同!
z532931406 + 1 + 1 无论何时要抱有希望,一切都会好起来的,加油
lxjqazg052 + 1 + 1 热心回复!
HuLZ2006 + 1 + 1 我很赞同!
Erdon7c + 1 + 1 加油
小懒虫 + 1 + 1 加油
NNovice丶 + 1 + 1 用心讨论,共获提升!
dmxayjn + 1 + 1 加油 向前看!!!!
shenxing + 1 + 1 热心回复!
52pojie10000 + 1 + 1 谢谢@Thanks!
laotzudao0 + 1 + 1 相信奇迹
森罗千引 + 1 + 1 诊断错误,好好活着。加油
Gold9T + 1 热心回复!
a1069942474 + 1 + 1 我很赞同!
745237896 + 1 + 1 谢谢@Thanks!
llee841020 + 1 + 1 我们终将离开 请活好每一天
18637598251 + 1 + 1 老哥,要加油啊,一定会好起来的
naixubao + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
liuxdsuyr + 1 兄弟,加油,干一天就胜利一天,每天都是新的
Dove702 + 1 + 1 加油!!!
fz52033 + 1 + 1 快点好起来,不要放弃
Scpkisl + 1 不要放弃!
雨濄添情 + 1 + 1 加油,不要放弃
安道尔的鱼 + 1 + 1 热心回复!
fz74110 + 2 + 1 兄弟,加油,
xizevip + 1 + 1 加油!
johnson1007 + 1 ,,,
styphen + 1 + 1 加油,兄弟
zch_546 + 1 + 1 愿平安!
lan74444 + 1 + 1 热心回复!
theStyx + 1 + 1 热心回复!
kanbekotaro + 1 鎰熻阿鍙戝竷鍘熷垱浣滃搧锛屽惥鐖辩牬瑙h鍧涘洜浣犳洿绮惧僵锛?
shiyue2925 + 1 + 1 谢谢@Thanks!
lianyuposui + 1 + 1 热心回复!
wangzhizhuo + 1 + 1 同95的,非常遗憾,兄弟加油啊!
sightwww + 1 + 1 唉。。。
kaixinmoney + 1 楼主,过开心点

查看全部评分

发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

推荐
汇成河流 发表于 2026-11-4 08:05
建议可以增加一个自己留言的功能,说一些想说的话,也可以开其他人留言的功能,但自己和别人的分页面存放,再留一个墓志铭在显眼位置,还能再开发一个网络墓地,存放在区块链
推荐
洞见未来 发表于 2026-11-3 19:15
现在很多癌症有对应的靶向药,多了解了解,加油,我邻居肺癌转移,在靶向药治疗下,目前和正常人一样生活快5年了。
推荐
 楼主| jockon 发表于 2026-11-6 18:00 |楼主
谢谢各位的鼓励,统一回复一下,我没有开玩笑,得的是脑干的弥漫性胶质瘤,3级或以上,位置特殊不能手术,从感觉不舒服到现在一共也就经历了两个多月,后面可能会经历一段时间放化疗,在化验病理找靶向药,不过这都是徒劳而已,生命就是那么充满戏剧性。

选github是因为这个平台可能不会那么容易关闭吧,也就是图个乐呵。手动签到、死亡,只是方便家人帮做一下,自动的任务执行怕忘记了有一个执行的空间。程序本身并不重要。

至于有人的建议加什么功能什么的,实在是没有精力管这个了,就这样吧。

点评

祝你开心每一天!!!  发表于 2026-11-8 15:13
加油 兄弟~~去北京天坛医院看看~!!  发表于 2026-11-7 00:24

免费评分

参与人数 2吾爱币 +3 热心值 +2 收起 理由
丶贤之 + 1 + 1 加油,兄弟
Sound + 2 + 1 奥利给!

查看全部评分

推荐
chaogezi333 发表于 2026-11-3 18:22
南无地藏王菩萨
推荐
 楼主| jockon 发表于 2026-11-10 07:42 |楼主
xfmiao 发表于 2026-11-10 00:15
第七天了,还在吗

没那么快
推荐
yixinyingX 发表于 2026-11-3 18:22
加油呀,坚持住!!!
推荐
江湖凡凡 发表于 2026-11-3 18:17
加油老哥。
5#
地瓜君 发表于 2026-11-3 18:15
加油啊哥们!
6#
MRBANK 发表于 2026-11-3 18:18
加油啊~
7#
bigmuzzy 发表于 2026-11-3 18:21
加油老哥。加油!
8#
congheerlai 发表于 2026-11-3 18:21
看到这个标题 心里紧了一下~ 哎
9#
woaininiaiwo 发表于 2026-11-3 18:41
哥们!加油,一切都会好起来的
10#
ghostOfTheWolf 发表于 2026-11-3 18:46
加油啊 兄弟.要坚持下去.万一呢
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - 52pojie.cn ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2026-11-11 18:08

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表