Compare commits

...

25 Commits

Author SHA1 Message Date
郑诚 (ZhengCheng)
7bfc5a4d23 Update README.md 2025-12-22 10:22:11 +08:00
郑诚 (ZhengCheng)
f1f63a4b51 docs: batch add 1 projects 2025-12-22 10:21:33 +08:00
郑诚 (ZhengCheng)
c698c87087 Update README.md
Some checks failed
提交项目(每 24 小时运行一次,晚上 00:00) / build (push) Has been cancelled
2025-12-21 10:34:08 +08:00
郑诚 (ZhengCheng)
ea155bd8d8 Merge pull request #667 from 1c7/batch-add-projects-20251221-023207
新增项目:批量添加 1 个项目
2025-12-21 10:33:04 +08:00
郑诚 (ZhengCheng)
508bf6c3c8 docs: batch add 1 projects 2025-12-21 10:32:09 +08:00
郑诚 (ZhengCheng)
3480b04a32 Update README-Game.md 2025-12-21 10:31:16 +08:00
Cheng Zheng
09b476b0bc doc
Some checks failed
提交项目(每 24 小时运行一次,晚上 00:00) / build (push) Has been cancelled
2025-12-20 14:36:56 +08:00
Cheng Zheng
2e133401c8 prompt 2025-12-20 14:33:50 +08:00
Cheng Zheng
f83699c075 doc 2025-12-20 14:32:53 +08:00
Cheng Zheng
875fa8c111 fix 2025-12-20 14:29:59 +08:00
Cheng Zheng
28ae2734d0 1条评论够了 2025-12-20 14:26:09 +08:00
郑诚 (ZhengCheng)
cd2b9e2243 Merge pull request #666 from 1c7/batch-add-projects-20251220-062313
新增项目:批量添加 3 个项目
2025-12-20 14:25:15 +08:00
郑诚 (ZhengCheng)
f12b822a55 Update README.md 2025-12-20 14:25:00 +08:00
郑诚 (ZhengCheng)
a7604c6648 docs: batch add 3 projects 2025-12-20 14:23:16 +08:00
Cheng Zheng
70d6df0ba7 fix 2025-12-20 14:22:25 +08:00
Cheng Zheng
53ef61c07e x 2025-12-20 14:17:39 +08:00
郑诚 (ZhengCheng)
fb5331e6e2 Merge pull request #665 from 1c7/add-project-3676752777
新增项目:来自 jankarong 的评论
2025-12-20 14:08:48 +08:00
郑诚 (ZhengCheng)
120c0bc4fa docs: add project from jankarong 2025-12-20 14:08:06 +08:00
Cheng Zheng
28b054672a fix 2025-12-20 14:00:55 +08:00
Cheng Zheng
fc867f0db9 fix 2025-12-20 13:57:54 +08:00
Cheng Zheng
442fd51ec0 save 2025-12-20 13:57:12 +08:00
Cheng Zheng
e83689f38c X 2025-12-20 13:51:08 +08:00
Cheng Zheng
e71a840143 log 2025-12-20 13:42:03 +08:00
Cheng Zheng
57e9b3e238 应该 OK 了 2025-12-20 13:38:41 +08:00
郑诚 (ZhengCheng)
811ae026ca Merge pull request #653 from 1c7/add-project-3670663918
新增项目:来自 hwlvipone 的评论
2025-12-20 13:37:26 +08:00
6 changed files with 194 additions and 94 deletions

View File

@@ -1,3 +1,3 @@
GITHUB_TOKEN="github_pat_*"
PAT_TOKEN="github_pat_*"
LLM_API_KEY="sk-*"
LLM_BASE_URL="https://api.deepseek.com"

View File

@@ -1,4 +1,4 @@
## `.github/` 的文档
## 介绍 `.github/` 文件夹的用途
## 概括
用户在 https://github.com/1c7/chinese-independent-developer/issues/160 提交评论。
@@ -6,7 +6,7 @@
需要用程序自动化处理,减少我的时间投入。
## 流程
1. 我在用户提交的评论点击 🚀 图标(表情)
1. 我1c7在用户提交的评论点击 🚀 图标(表情)
1. 触发 Github Action 执行(手动触发 或 定时执行(每 6 小时)
1. Github Action 会触发 .github/scripts/process_item.py
2. 查找 "当前日期-3天" 开始(这个时间点往后) 所有标记 🚀 图标 的评论
@@ -26,4 +26,3 @@ uv sync
uv run .github/scripts/process_item.py
```

View File

@@ -1,145 +1,217 @@
import os
import re
import datetime
from github import Github # https://github.com/PyGithub/PyGithub
from github import Github
from openai import OpenAI
from datetime import datetime, timedelta, timezone
# ================= 配置区 =================
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
API_KEY = os.getenv("LLM_API_KEY")
BASE_URL = os.getenv("LLM_BASE_URL", "https://api.openai.com/v1")
REPO_NAME = "1c7/chinese-independent-developer" # os.getenv("GITHUB_REPOSITORY")
ISSUE_NUMBER = 160 # 你在维护的那个 Issue 编号
ADMIN_HANDLE = "1c7" # 替换为你的 GitHub ID
TRIGGER_EMOJI = "rocket" # 🚀
SUCCESS_EMOJI = "hooray" # 🎉
PAT_TOKEN = os.getenv("PAT_TOKEN") # GitHub Personal Access Token
API_KEY = os.getenv("LLM_API_KEY") # LLM API 密钥(如 DeepSeek、OpenAI
BASE_URL = os.getenv("LLM_BASE_URL", "https://api.openai.com/v1") # LLM API 基础 URL
REPO_NAME = "1c7/chinese-independent-developer" # GitHub 仓库名称
ISSUE_NUMBER = 160 # 用于收集项目提交的 Issue 编号
ADMIN_HANDLE = "1c7" # 管理员 GitHub 用户名
TRIGGER_EMOJI = "rocket" # 触发处理的表情符号 🚀
SUCCESS_EMOJI = "hooray" # 处理成功的表情符号 🎉
# ==========================================
def check_environment():
"""检查必需的环境变量是否存在"""
if not PAT_TOKEN:
raise ValueError("❌ 缺少环境变量 PAT_TOKEN请设置 GitHub Personal Access Token。")
if not API_KEY:
raise ValueError("❌ 缺少环境变量 LLM_API_KEY请设置 LLM API Key。")
print(f"✅ 环境变量检查通过")
print(f" - PAT_TOKEN: {'*' * 10}{PAT_TOKEN[-4:]}")
print(f" - API_KEY: {'*' * 10}{API_KEY[-4:]}")
print(f" - BASE_URL: {BASE_URL}\n")
def remove_quote_blocks(text: str) -> str:
"""移除 GitHub 引用回复块(以 > 开头的行)"""
"""移除 GitHub 引用回复块"""
lines = text.split('\n')
cleaned_lines = []
for line in lines:
# 检查去除前导空格后是否以 > 开头
if not line.lstrip().startswith('>'):
cleaned_lines.append(line)
# 重新拼接,并清理多余空行
result = '\n'.join(cleaned_lines)
# 移除连续多个空行,保留单个空行
result = re.sub(r'\n{3,}', '\n\n', result)
return result.strip()
def get_ai_format(raw_text):
def get_ai_project_line(raw_text):
"""让 AI 提取项目名称、链接和描述(支持多个产品)"""
client = OpenAI(api_key=API_KEY, base_url=BASE_URL)
prompt = f"""
你是一个严格的文案编辑。任务将用户的项目介绍转换为标准的 Markdown 格式。
任务将用户的项目介绍转换为 Markdown 格式。
4. 格式模板
#### 制作者名字 - [Github](链接)
* :white_check_mark: [项目名](链接):用途描述
要求
1. 识别文本中的所有产品/项目(可能有多个)
2. 每个项目占一行
3. 在文字的开头,去掉"一款、一个、完全免费、高效、简洁、强大、快速、好用、安全"等营销废话
4. 严禁使用加粗格式(不要使用 **
5. 将产品名称从文字的后面提升到最前面
6. 每行格式:* :white_check_mark: [项目名](网址):用途描述
示例 1
输入https://example.com一款基于 AI 的高效视频生成网站
输出:* :white_check_mark: [example.com](https://example.com)AI 视频生成网站
示例 2
输入:[MyApp](https://myapp.com) 完全免费的强大工具,帮助用户管理任务
输出:* :white_check_mark: [MyApp](https://myapp.com):任务管理工具
示例 3多个项目
输入:
[ProductA](https://a.com)AI 绘画工具
[ProductB](https://b.com)AI 写作助手
输出:
* :white_check_mark: [ProductA](https://a.com)AI 绘画工具
* :white_check_mark: [ProductB](https://b.com)AI 写作助手
待处理文本:
{raw_text}
"""
response = client.chat.completions.create(
model="deepseek-reasoner", # 或者使用 deepseek-chat
model="deepseek-chat",
messages=[{"role": "user", "content": prompt}],
temperature=0.3
)
return response.choices[0].message.content.strip()
def main():
g = Github(GITHUB_TOKEN)
# 检查环境变量
check_environment()
g = Github(PAT_TOKEN)
repo = g.get_repo(REPO_NAME)
issue = repo.get_issue(ISSUE_NUMBER)
# 计算 3 天前的时间GitHub API 使用的是 UTC 时间)
time_threshold = datetime.now(timezone.utc) - timedelta(days=3)
# 如果你一定要死守 2025-12-15也可以手动指定
# time_threshold = datetime(2025, 12, 15, tzinfo=timezone.utc)
# 重点:在这里加上 since 参数
comments = issue.get_comments(since=time_threshold)
processed_count = 0
# ===== 阶段 1收集待处理评论 =====
pending_comments = []
formatted_entries = []
for comment in comments:
# 1. 检查是否有你的 🚀 反应
reactions = comment.get_reactions()
has_trigger = any(r.content == TRIGGER_EMOJI and r.user.login == ADMIN_HANDLE for r in reactions)
# 2. 检查是否已经标记过成功 🎉
has_success = any(r.content == SUCCESS_EMOJI for r in reactions)
if has_trigger and not has_success:
print(f"发现待处理评论 ID: {comment.id}")
print(f"\n{'='*60}")
print(f"处理评论:\n{comment.body}")
print(f"\n评论链接:{comment.html_url}")
print(f"{'='*60}\n")
# 清理引用块,然后 AI 格式化内容
cleaned_body = remove_quote_blocks(comment.body)
formatted_entry = get_ai_format(cleaned_body)
# 准备修改 README.md
content = repo.get_contents("README.md", ref="master")
readme_text = content.decoded_content.decode("utf-8")
# 插入日期逻辑
today_str = datetime.now().strftime("%Y 年 %m 月 %d 号添加")
date_header = f"### {today_str}"
if date_header not in readme_text:
# 在 "3. 项目列表" 下方插入新日期
new_readme = readme_text.replace("3. 项目列表\n", f"3. 项目列表\n\n{date_header}\n")
# 判断用户是否自带了 Header
header_match = re.search(r'^####\s+.*', cleaned_body, re.MULTILINE)
if header_match:
header_line = header_match.group(0).strip()
body_for_ai = cleaned_body.replace(header_line, "").strip()
print(f"检测到用户自带 Header: {header_line}")
else:
new_readme = readme_text
author_name = comment.user.login
author_url = comment.user.html_url
header_line = f"#### {author_name} - [Github]({author_url})"
body_for_ai = cleaned_body
print(f"自动生成 Header: {header_line}")
# 在日期标题下插入新条目
insertion_point = new_readme.find(date_header) + len(date_header)
final_readme = new_readme[:insertion_point] + "\n\n" + formatted_entry + new_readme[insertion_point:]
# AI 处理项目详情行
project_line = get_ai_project_line(body_for_ai)
formatted_entry = f"{header_line}\n{project_line}"
# 创建新分支并提交 PR
branch_name = f"add-project-{comment.id}"
base = repo.get_branch("master")
pending_comments.append(comment)
formatted_entries.append(formatted_entry)
# 检查分支是否已存在,如果存在则删除
try:
existing_ref = repo.get_git_ref(f"heads/{branch_name}")
existing_ref.delete()
print(f"已删除现有分支: {branch_name}")
except:
pass # 分支不存在,继续
# ===== 阶段 2批量提交 =====
if not pending_comments:
print("无待处理评论")
return
repo.create_git_ref(ref=f"refs/heads/{branch_name}", sha=base.commit.sha)
repo.update_file(
"README.md",
f"docs: add new project from comment {comment.id}",
final_readme,
content.sha,
branch=branch_name
)
print(f"\n共收集 {len(pending_comments)} 个待处理评论")
pr = repo.create_pull(
title=f"新增项目:来自评论 {comment.id}",
body=f"{comment.body}\n\n---\n原始评论:`{comment.html_url}`",
head=branch_name,
base="master"
)
# 更新 README
content = repo.get_contents("README.md", ref="master")
readme_text = content.decoded_content.decode("utf-8")
# 用表情标记为成功,并回复
comment.create_reaction(SUCCESS_EMOJI)
# comment.create_comment(f"感谢提交,已添加!\n\nPR 链接:{pr.html_url}")
processed_count += 1
print(f"评论 {comment.id} 处理成功,已创建 PR。")
today_str = datetime.now().strftime("%Y 年 %m 月 %d 号添加")
date_header = f"### {today_str}"
if processed_count == 0:
print("没有发现需要处理的新评论。")
if date_header not in readme_text:
new_readme = readme_text.replace("3. 项目列表\n", f"3. 项目列表\n\n{date_header}\n")
else:
new_readme = readme_text
# 插入所有条目(用两个换行分隔)
insertion_point = new_readme.find(date_header) + len(date_header)
all_entries = "\n\n".join(formatted_entries)
final_readme = new_readme[:insertion_point] + "\n\n" + all_entries + new_readme[insertion_point:]
# 创建分支
branch_name = f"batch-add-projects-{datetime.now().strftime('%Y%m%d-%H%M%S')}"
base = repo.get_branch("master")
try:
repo.get_git_ref(f"heads/{branch_name}").delete()
except:
pass
repo.create_git_ref(ref=f"refs/heads/{branch_name}", sha=base.commit.sha)
repo.update_file(
"README.md",
f"docs: batch add {len(pending_comments)} projects",
final_readme,
content.sha,
branch=branch_name
)
# 构建 PR body
comment_links = "\n".join([
f"- [{c.user.login}]({c.html_url})"
for c in pending_comments
])
formatted_list = "\n\n".join([
f"### {i+1}. {formatted_entries[i]}"
for i in range(len(formatted_entries))
])
pr_body = f"""批量添加 {len(pending_comments)} 个项目
## 原始评论链接
{comment_links}
## 格式化结果
{formatted_list}
---
自动生成,触发机制:用户 {ADMIN_HANDLE} 点击 🚀
"""
pr = repo.create_pull(
title=f"新增项目:批量添加 {len(pending_comments)} 个项目",
body=pr_body,
head=branch_name,
base="master"
)
print(f"\n✅ PR 创建成功:{pr.html_url}")
# 标记所有评论(添加 🎉 表情)
for comment in pending_comments:
comment.create_reaction(SUCCESS_EMOJI)
# 创建一条评论提及所有用户
user_mentions = " ".join([f"@{c.user.login}" for c in pending_comments])
reply_body = f"{user_mentions} 感谢提交,已添加!\n\n PR 链接:{pr.html_url}"
issue.create_comment(reply_body)
print(f"\n✅ 已标记所有 {len(pending_comments)} 个评论")
if __name__ == "__main__":
main()

View File

@@ -1,7 +1,7 @@
name: 提交项目
name: 提交项目(每 24 小时运行一次,晚上 00:00
on:
# schedule:
# - cron: '0 */6 * * *' # 每 6 小时运行一次
schedule:
- cron: '0 16 * * *' # 每天 UTC 16:00 运行(北京时间 00:00
workflow_dispatch: # 支持手动触发
jobs:
@@ -22,7 +22,7 @@ jobs:
- name: Run script
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
# 如果你用的不是 OpenAI 原生接口,可以设置这个环境变量,否则默认使用 OpenAI
LLM_BASE_URL: "https://api.deepseek.com"

View File

@@ -2,6 +2,10 @@
本版面放的都是游戏起始于2025年1月4号
### 2025 年 12 月 21 号添加
#### shuiwuhen - [GitHub](https://github.com/290713469)
* :white_check_mark: [Universal Tower Defense Calculator](https://universaltowerdefensecalculator.com)Roblox 游戏 Universal Tower Defense 工具站
### 2025 年 12 月 14 号添加
#### seven(沈阳)
* :white_check_mark: [Pips game](https://pipsgame.dev/): 每日逻辑谜题你通过纯推理放置多米诺骨牌——无需猜测Pips Game is a daily logic puzzle where you place dominoes using pure deduction — no guessing

View File

@@ -20,7 +20,32 @@
## 3. 项目列表
### 2025 年 12 月 22 号添加
#### zhugezifang - [Github](https://github.com/zhugezifang)
* :white_check_mark: [颜值评分](https://howattractiveami.app/zh)AI 颜值测试
* :white_check_mark: [在线眼型测试](https://eyeshapedetector.app/zh)AI 眼型分析
* :white_check_mark: [面部年龄计算器](https://howolddoyoulook.app/zh)AI 面部年龄检测器
### 2025 年 12 月 21 号添加
#### azt1112 - [Github](https://github.com/azt1112)
* :white_check_mark: [GPT Image 1.5](https://chatgptimage15.com/)AI 图片生成网站,基于 GPT Image 1.5
### 2025 年 12 月 20 号添加
#### yoga666yoga888-lgtm - [Github](https://github.com/yoga666yoga888-lgtm)
* :white_check_mark: [Sora21](https://www.sora21.com/):视频生成网站,基于 Sora2 模型,高性价比
#### hwlvipone - [Github](https://github.com/hwlvipone)
* :white_check_mark: [palm reading online](https://palm-reading.app/)AI 看手相网站
#### allen2peace - [Github](https://github.com/allen2peace)
* :white_check_mark: [FluentDictation](http://fluentdictation.com/):使用任意 YouTube 视频练习英语听写、英语跟读能力
#### jankarong - [Github](https://github.com/jankarong)
* :white_check_mark: [AI YouTube 缩略图生成器](https://aithumbnailcreator.com/):生成 Youtube 缩略图,可免费下载,支持纯色或渐变背景
#### hwlvipone - [Github](https://github.com/hwlvipone)
* :white_check_mark: [ZestyGen](https://zestygen.com/):基于 Nano Banana Pro 的图片视频聚合网站