⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 智能筛选新闻 + AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。
Python aibarkdata-analysisdockerhot-newsllmmailmcpmcp-servernewsntfypythonrsstrending-topicswechatwework
chore: 修复 manage.py 安全隐患,迁移飞书推送文档至群组自定义机器人
sansan64c99192e57f
diff --git a/README-EN.md b/README-EN.mdindex e499a8d062..adfe562a7f 100644--- a/README-EN.md+++ b/README-EN.md@@ -1265,84 +1265,45 @@ Transform from "algorithm recommendation captivity" to "actively getting the inf<summary> <strong>👉 Click to expand: Feishu Bot</strong> (Message display is relatively friendly)</summary><br>+> **Note**: The original "Feishu BotBuilder" will be discontinued on June 30, 2026. Please use the **Custom Group Bot** method below. Existing BotBuilder webhook URLs will no longer work and need to be reconfigured.+**Note**: If **AI Analysis** is enabled, Feishu push notifications may occasionally (approx. 5% probability) experience a few minutes of delay. This is likely due to the platform's internal compliance auditing for AI-generated content.**GitHub Secret Configuration (⚠️ Name must match exactly):**- **Name**: `FEISHU_WEBHOOK_URL` (Please copy and paste this name, do not type manually)-- **Secret (Value)**: Your Feishu bot Webhook address (link starts with https://www.feishu.cn/flow/api/trigger-webhook/********)-<br>--Two methods available, **Method 1** is simpler, **Method 2** is more complex (but stable push)--Method 1 discovered and suggested by **ziventian**, thanks to them. Default is personal push, group push can be configured via [#97](https://github.com/sansan0/TrendRadar/issues/97)--**Method 1:**--> For some users, additional operations needed to avoid "System Error". Need to search for the bot on mobile and enable Feishu bot application (suggestion from community, can refer)--1. Open in PC browser https://botbuilder.feishu.cn/home/my-command--2. Click "New Bot Command"--3. Click "Select Trigger", scroll down, click "Webhook Trigger"--4. Now you'll see "Webhook Address", copy this link to local notepad temporarily, continue with next steps--5. In "Parameters" put the following content, then click "Done"--```json-{- "message_type": "text",- "content": {- "text": "{{Content}}"- }-}-```--6. Click "Select Action" > "Send via Official Bot"--7. Message title fill "TrendRadar Trending Monitor"--8. Most critical part, click + button, select "Webhook Trigger", then arrange as shown in image--+- **Secret (Value)**: Your Feishu custom bot Webhook address (format: `https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxxx`)-9. After configuration, put Webhook address from step 4 into GitHub Secrets `FEISHU_WEBHOOK_URL`+**Configuration Steps:**-<br>+1. Enter the target group, click the **More** button at the top right of the group, and click **Settings**.-**Method 2:**+-1. Open in PC browser https://botbuilder.feishu.cn/home/my-app+2. In the **Settings** panel on the right, click **Group Bots**.-2. Click "New Bot Application"+-3. After entering the created application, click "Process Design" > "Create Process" > "Select Trigger"+3. In the **Group Bots** panel, click **Add Bot**.-4. Scroll down, click "Webhook Trigger"+4. In the **Add Bot** dialog, find and click **Custom Bot**.-5. Now you'll see "Webhook Address", copy this link to local notepad temporarily, continue with next steps+-6. In "Parameters" put the following content, then click "Done"+5. Set the custom bot's avatar, name (e.g., "TrendRadar Trending Monitor") and description, then click **Add**.-```json-{- "message_type": "text",- "content": {- "text": "{{Content}}"- }-}-```+-7. Click "Select Action" > "Send Feishu Message", check "Group Message", then click the input box below, click "Groups I Manage" (if no group, you can create one in Feishu app)+6. Copy the custom bot's **webhook address**, and click **Done**.-8. Message title fill "TrendRadar Trending Monitor"+> ⚠️ Please keep this webhook address safe. Do not publish it on GitHub, blogs, or any publicly accessible websites to prevent unauthorized use.-9. Most critical part, click + button, select "Webhook Trigger", then arrange as shown in image+-+7. Configure the copied Webhook address in GitHub Secrets as `FEISHU_WEBHOOK_URL`.-10. After configuration, put Webhook address from step 5 into GitHub Secrets `FEISHU_WEBHOOK_URL`+> 💡 After configuration, you can click the bot avatar next to the group name to enter the custom bot details page and manage its settings.+>+> 📖 Official documentation: [Custom Bot Guide](https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot)</details>diff --git a/README.md b/README.mdindex bf5161e016..1f101edd63 100644--- a/README.md+++ b/README.md@@ -1319,84 +1319,45 @@ ai_translation:<summary>👉 点击展开:<strong>飞书机器人</strong>(消息显示相对友好)</summary><br>+ > **注意**:原「飞书机器人助手 (BotBuilder)」将于 2026 年 6 月 30 日下线,请使用下方的**群组自定义机器人**方式配置。已有的 BotBuilder webhook 地址将失效,需要重新配置。+若启用 **AI 分析**,飞书推送偶发(约 5% 概率)会有数分钟延迟(推测为平台对 AI 生成内容的合规性审核)。**GitHub Secret 配置(⚠️ Name 名称必须严格一致):**- **Name(名称)**:`FEISHU_WEBHOOK_URL`(请复制粘贴此名称,不要手打)- - **Secret(值)**:你的飞书机器人 Webhook 地址(该链接开头类似 https://www.feishu.cn/flow/api/trigger-webhook/********)- <br>-- 有两个方案,**方案一**配置简单,**方案二**配置复杂(但是稳定推送)-- 其中方案一,由 **ziventian**发现并提供建议,在这里感谢他,默认是个人推送,也可以配置群组推送操作[#97](https://github.com/sansan0/TrendRadar/issues/97) ,-- **方案一:**-- > 对部分人存在额外操作,否则会报"系统错误"。需要手机端搜索下机器人,然后开启飞书机器人应用(该建议来自于网友,可参考)-- 1. 电脑浏览器打开 https://botbuilder.feishu.cn/home/my-command-- 2. 点击"新建机器人指令"-- 3. 点击"选择触发器",往下滑动,点击"Webhook 触发"-- 4. 此时你会看到"Webhook 地址",把这个链接先复制到本地记事本暂存,继续接下来的操作-- 5. "参数"里面放上下面的内容,然后点击"完成"-- ```json- {- "message_type": "text",- "content": {- "text": "{{内容}}"- }- }- ```-- 6. 点击"选择操作" > "通过官方机器人发消息"-- 7. 消息标题填写"TrendRadar 热点监控"-- 8. 最关键的部分来了,点击 + 按钮,选择"Webhook 触发",然后按照下面的图片摆放-- + - **Secret(值)**:你的飞书自定义机器人 Webhook 地址(格式:`https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxxx`)- 9. 配置完成后,将第 4 步复制的 Webhook 地址配置到 GitHub Secrets 中的 `FEISHU_WEBHOOK_URL`+ **配置步骤:**- <br>+ 1. 进入目标群组,在群组右上角点击 **更多** 按钮,并点击 **设置**。- **方案二:**+ - 1. 电脑浏览器打开 https://botbuilder.feishu.cn/home/my-app+ 2. 在右侧 **设置** 界面,点击 **群机器人**。- 2. 点击"新建机器人应用"+ - 3. 进入创建的应用后,点击"流程设计" > "创建流程" > "选择触发器"+ 3. 在 **群机器人** 界面点击 **添加机器人**。- 4. 往下滑动,点击"Webhook 触发"+ 4. 在 **添加机器人** 对话框,找到并点击 **自定义机器人**。- 5. 此时你会看到"Webhook 地址",把这个链接先复制到本地记事本暂存,继续接下来的操作+ - 6. "参数"里面放上下面的内容,然后点击"完成"+ 5. 设置自定义机器人的头像、名称(如"TrendRadar 热点监控")与描述,并点击 **添加**。- ```json- {- "message_type": "text",- "content": {- "text": "{{内容}}"- }- }- ```+ - 7. 点击"选择操作" > "发送飞书消息",勾选 "群消息",然后点击下面的输入框,点击"我管理的群组"(如果没有群组,你可以在飞书 app 上创建群组)+ 6. 获取自定义机器人的 **webhook 地址**,并点击 **完成**。- 8. 消息标题填写"TrendRadar 热点监控"+ > ⚠️ 请妥善保存此 webhook 地址,不要公布在 GitHub、博客等可公开查阅的网站上,避免地址泄露后被恶意调用发送垃圾消息。- 9. 最关键的部分来了,点击 + 按钮,选择"Webhook 触发",然后按照下面的图片摆放+ - + 7. 将复制的 Webhook 地址配置到 GitHub Secrets 中的 `FEISHU_WEBHOOK_URL`。- 10. 配置完成后,将第 5 步复制的 Webhook 地址配置到 GitHub Secrets 中的 `FEISHU_WEBHOOK_URL`+ > 💡 配置完成后,你可以在群组名称右侧点击机器人图片,进入自定义机器人详情页,管理配置信息。+ >+ > 📖 官方文档:[自定义机器人使用指南](https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot)</details>diff --git a/_image/feishu-bot/step1-group-settings.png b/_image/feishu-bot/step1-group-settings.pngnew file mode 100644index 0000000000..25c469abf8Binary files /dev/null and b/_image/feishu-bot/step1-group-settings.png differdiff --git a/_image/feishu-bot/step2-group-bot.png b/_image/feishu-bot/step2-group-bot.pngnew file mode 100644index 0000000000..78170c2b3cBinary files /dev/null and b/_image/feishu-bot/step2-group-bot.png differdiff --git a/_image/feishu-bot/step3-custom-bot.png b/_image/feishu-bot/step3-custom-bot.pngnew file mode 100644index 0000000000..321c273c8cBinary files /dev/null and b/_image/feishu-bot/step3-custom-bot.png differdiff --git a/_image/feishu-bot/step4-set-name.png b/_image/feishu-bot/step4-set-name.pngnew file mode 100644index 0000000000..da961e10e2Binary files /dev/null and b/_image/feishu-bot/step4-set-name.png differdiff --git a/_image/feishu-bot/step5-webhook-url.png b/_image/feishu-bot/step5-webhook-url.pngnew file mode 100644index 0000000000..a07ca22a13Binary files /dev/null and b/_image/feishu-bot/step5-webhook-url.png differdiff --git a/docker/manage.py b/docker/manage.pyindex be1bce2eb5..d58685c400 100644--- a/docker/manage.py+++ b/docker/manage.py@@ -10,26 +10,12 @@ import subprocessimport timeimport signalfrom pathlib import Path-from datetime import datetime# Web 服务器配置-WEBSERVER_PORT = int(os.environ.get("WEBSERVER_PORT", "8080"))+_raw_port = int(os.environ.get("WEBSERVER_PORT", "8080"))+WEBSERVER_PORT = _raw_port if 1 <= _raw_port <= 65535 else 8080WEBSERVER_DIR = "/app/output"WEBSERVER_PID_FILE = "/tmp/webserver.pid"-def get_timestamp():- """获取当前时间戳字符串"""- return datetime.now().strftime("%Y-%m-%d %H:%M:%S")---def run_command(cmd, shell=True, capture_output=True):- """执行系统命令"""- try:- result = subprocess.run(- cmd, shell=shell, capture_output=capture_output, text=True- )- return result.returncode == 0, result.stdout, result.stderr- except Exception as e:- return False, "", str(e)def manual_run():@@ -136,10 +122,10 @@ def show_status():supercronic_is_pid1 = Falsepid1_cmdline = ""try:- with open('/proc/1/cmdline', 'r') as f:- pid1_cmdline = f.read().replace('\x00', ' ').strip()+ with open('/proc/1/cmdline', 'rb') as f:+ pid1_cmdline = f.read().replace(b'\x00', b' ').decode('utf-8', errors='ignore').strip()print(f" 🔍 PID 1 进程: {pid1_cmdline}")-+if "supercronic" in pid1_cmdline.lower():print(" ✅ supercronic 正确运行为 PID 1")supercronic_is_pid1 = True@@ -191,7 +177,7 @@ def show_status():with open(file_path, 'r') as f:crontab_content = f.read().strip()print(f" 内容: {crontab_content}")- except:+ except Exception:passelse:print(f" ❌ {description}: 不存在")@@ -311,7 +297,7 @@ def show_config():for var in env_vars:value = os.environ.get(var, "未设置")# 隐藏敏感信息- if any(sensitive in var for sensitive in ["WEBHOOK", "TOKEN", "KEY", "SECRET"]):+ if var == "BARK_URL" or any(sensitive in var for sensitive in ["WEBHOOK", "TOKEN", "KEY", "SECRET"]):if value and value != "未设置":masked_value = value[:10] + "***" if len(value) > 10 else "***"print(f" {var}: {masked_value}")@@ -434,8 +420,8 @@ def restart_supercronic():# 检查当前 PID 1try:- with open('/proc/1/cmdline', 'r') as f:- pid1_cmdline = f.read().replace('\x00', ' ').strip()+ with open('/proc/1/cmdline', 'rb') as f:+ pid1_cmdline = f.read().replace(b'\x00', b' ').decode('utf-8', errors='ignore').strip()print(f" 🔍 当前 PID 1: {pid1_cmdline}")if "supercronic" in pid1_cmdline.lower():@@ -511,15 +497,17 @@ def _is_webserver_running(pid: int) -> bool:try:import urllib.request+ class _NoRedirect(urllib.request.HTTPRedirectHandler):+ def redirect_request(self, req, fp, code, msg, headers, newurl):+ raise urllib.error.HTTPError(req.full_url, code, msg, headers, fp)+ opener = urllib.request.build_opener(_NoRedirect)req = urllib.request.Request(f"http://127.0.0.1:{WEBSERVER_PORT}/", method="HEAD")- urllib.request.urlopen(req, timeout=3)+ opener.open(req, timeout=3)return Trueexcept Exception:try:time.sleep(1)- import urllib.request- req = urllib.request.Request(f"http://127.0.0.1:{WEBSERVER_PORT}/", method="HEAD")- urllib.request.urlopen(req, timeout=3)+ opener.open(req, timeout=3)return Trueexcept Exception:return False@@ -622,7 +610,7 @@ def stop_webserver():# 尝试清理 PID 文件try:os.remove(WEBSERVER_PID_FILE)- except:+ except Exception:pass