v3.1.0 增加【个人微信】推送方案

This commit is contained in:
sansan 2025-11-20 13:22:58 +08:00
parent 170364b14e
commit a3d0032604
9 changed files with 339 additions and 158 deletions

View File

@ -53,6 +53,7 @@ jobs:
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
DINGTALK_WEBHOOK_URL: ${{ secrets.DINGTALK_WEBHOOK_URL }} DINGTALK_WEBHOOK_URL: ${{ secrets.DINGTALK_WEBHOOK_URL }}
WEWORK_WEBHOOK_URL: ${{ secrets.WEWORK_WEBHOOK_URL }} WEWORK_WEBHOOK_URL: ${{ secrets.WEWORK_WEBHOOK_URL }}
WEWORK_MSG_TYPE: ${{ secrets.WEWORK_MSG_TYPE }}
EMAIL_FROM: ${{ secrets.EMAIL_FROM }} EMAIL_FROM: ${{ secrets.EMAIL_FROM }}
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }} EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
EMAIL_TO: ${{ secrets.EMAIL_TO }} EMAIL_TO: ${{ secrets.EMAIL_TO }}

View File

@ -13,10 +13,11 @@
[![GitHub Stars](https://img.shields.io/github/stars/sansan0/TrendRadar?style=flat-square&logo=github&color=yellow)](https://github.com/sansan0/TrendRadar/stargazers) [![GitHub Stars](https://img.shields.io/github/stars/sansan0/TrendRadar?style=flat-square&logo=github&color=yellow)](https://github.com/sansan0/TrendRadar/stargazers)
[![GitHub Forks](https://img.shields.io/github/forks/sansan0/TrendRadar?style=flat-square&logo=github&color=blue)](https://github.com/sansan0/TrendRadar/network/members) [![GitHub Forks](https://img.shields.io/github/forks/sansan0/TrendRadar?style=flat-square&logo=github&color=blue)](https://github.com/sansan0/TrendRadar/network/members)
[![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg?style=flat-square)](LICENSE) [![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg?style=flat-square)](LICENSE)
[![Version](https://img.shields.io/badge/version-v3.0.5-blue.svg)](https://github.com/sansan0/TrendRadar) [![Version](https://img.shields.io/badge/version-v3.1.0-blue.svg)](https://github.com/sansan0/TrendRadar)
[![MCP](https://img.shields.io/badge/MCP-v1.0.2-green.svg)](https://github.com/sansan0/TrendRadar) [![MCP](https://img.shields.io/badge/MCP-v1.0.2-green.svg)](https://github.com/sansan0/TrendRadar)
[![WeWork](https://img.shields.io/badge/WeWork-Notification-00D4AA?style=flat-square)](https://work.weixin.qq.com/) [![WeWork](https://img.shields.io/badge/WeWork-Notification-00D4AA?style=flat-square)](https://work.weixin.qq.com/)
[![WeChat](https://img.shields.io/badge/WeChat-Notification-00D4AA?style=flat-square)](https://weixin.qq.com/)
[![Telegram](https://img.shields.io/badge/Telegram-Notification-00D4AA?style=flat-square)](https://telegram.org/) [![Telegram](https://img.shields.io/badge/Telegram-Notification-00D4AA?style=flat-square)](https://telegram.org/)
[![DingTalk](https://img.shields.io/badge/DingTalk-Notification-00D4AA?style=flat-square)](#) [![DingTalk](https://img.shields.io/badge/DingTalk-Notification-00D4AA?style=flat-square)](#)
[![Feishu](https://img.shields.io/badge/Feishu-Notification-00D4AA?style=flat-square)](https://www.feishu.cn/) [![Feishu](https://img.shields.io/badge/Feishu-Notification-00D4AA?style=flat-square)](https://www.feishu.cn/)
@ -250,11 +251,18 @@ Transform from "algorithm recommendation captivity" to "actively getting the inf
- **Major Version Upgrade**: Upgrading from v1.x to v2.y, recommend deleting existing fork and re-forking to save effort and avoid config conflicts - **Major Version Upgrade**: Upgrading from v1.x to v2.y, recommend deleting existing fork and re-forking to save effort and avoid config conflicts
### 2025/11/12 - v3.0.5 ### 2025/11/20 - v3.1.0
- Fixed email sending SSL/TLS port configuration logic error - **Added Personal WeChat Push Support**: WeWork application can push to personal WeChat without installing WeWork APP
- Optimized email service providers (QQ/163/126) to default use port 465 (SSL) - Supports two message formats: `markdown` (WeWork group bot) and `text` (personal WeChat app)
- **Added Docker environment variable support**: Core config items (`enable_crawler`, `report_mode`, `push_window`, etc.) support override via environment variables, solving config file modification issues for NAS users (see [🐳 Docker Deployment](#-docker-deployment) chapter) - Added `WEWORK_MSG_TYPE` environment variable configuration, supporting GitHub Actions, Docker, docker-compose and other deployment methods
- `text` mode automatically strips Markdown syntax for clean plain text push
- See "Personal WeChat Push" configuration in Quick Start
**Upgrade Instructions** (GitHub Fork Users):
- Required updates: `main.py`, `config/config.yaml`
- Optional update: `.github/workflows/crawler.yml` (if using GitHub Actions)
- Recommended: Use minor version upgrade method - copy and replace the files above
@ -267,6 +275,13 @@ Transform from "algorithm recommendation captivity" to "actively getting the inf
<details> <details>
<summary><strong>👉 Click to expand: Historical Updates</strong></summary> <summary><strong>👉 Click to expand: Historical Updates</strong></summary>
### 2025/11/12 - v3.0.5
- Fixed email sending SSL/TLS port configuration logic error
- Optimized email service providers (QQ/163/126) to default use port 465 (SSL)
- **Added Docker environment variable support**: Core config items (`enable_crawler`, `report_mode`, `push_window`, etc.) support override via environment variables, solving config file modification issues for NAS users (see [🐳 Docker Deployment](#-docker-deployment) chapter)
### 2025/10/26 - mcp-v1.0.1 ### 2025/10/26 - mcp-v1.0.1
**MCP Module Update:** **MCP Module Update:**
@ -595,6 +610,37 @@ frequency_words.txt file added **required word** feature, using + sign
#### PC Setup Process Similar #### PC Setup Process Similar
</details> </details>
<details>
<summary> <strong>👉 Click to expand: Personal WeChat Push</strong> (Based on WeWork app, push to personal WeChat)</summary>
<br>
> This solution is based on WeWork's plugin mechanism. The push style is plain text (no markdown format), but it can push directly to personal WeChat without installing WeWork App.
**GitHub Secret Configuration (⚠️ Name must match exactly):**
- **Name**: `WEWORK_WEBHOOK_URL` (Please copy and paste this name, do not type manually)
- **Secret (Value)**: Your WeWork app Webhook address
- **Name**: `WEWORK_MSG_TYPE` (Please copy and paste this name, do not type manually)
- **Secret (Value)**: `text`
<br>
**Setup Steps:**
1. Complete the WeWork bot Webhook setup above
2. Add `WEWORK_MSG_TYPE` Secret with value `text`
3. Follow the image below to link personal WeChat
4. After configuration, WeWork App can be deleted from phone
<img src="_image/wework.png" title="Personal WeChat Push Configuration"/>
**Notes**:
- Uses the same Webhook address as WeWork bot
- Difference is message format: `text` for plain text, `markdown` for rich text (default)
- Plain text format will automatically remove all markdown syntax (bold, links, etc.)
</details>
<details> <details>
<summary> <strong>👉 Click to expand: Feishu Bot</strong> (Most user-friendly message display)</summary> <summary> <strong>👉 Click to expand: Feishu Bot</strong> (Most user-friendly message display)</summary>
<br> <br>
@ -987,6 +1033,31 @@ frequency_words.txt file added **required word** feature, using + sign
**Note**: Suggest only adjusting explicitly documented config items, other options mainly for author's development testing **Note**: Suggest only adjusting explicitly documented config items, other options mainly for author's development testing
5. **🎉 Deployment Success! Share Your Experience**
Congratulations on completing TrendRadar configuration! You can now start tracking trending news.
💬 **Join our community to share your experience~**
- Want to learn more tips and advanced techniques?
- Need quick help with issues?
- Have great ideas to share?
👉 **Follow our WeChat Official Account「硅基茶水间」(Silicon Tea Room)**, your likes and comments are the driving force for continuous updates!
For detailed communication methods, please check → [FAQ & Support](#-faq--support)
6. **🤖 Want Smarter Analysis? Try AI-Enhanced Features** (Optional)
Basic configuration already meets daily needs, but if you want:
- 📊 Let AI automatically analyze trending topics and data insights
- 🔍 Search and query news using natural language
- 💡 Get sentiment analysis, topic prediction, and deep analytics
- ⚡ Directly access data in AI tools like Claude, Cursor, etc.
👉 **Learn More**: [AI Analysis](#-ai-analysis) — Unlock hidden capabilities and make trend tracking more efficient!
## ⚙️ Configuration Guide ## ⚙️ Configuration Guide
@ -1853,37 +1924,27 @@ Any client supporting Model Context Protocol can connect to TrendRadar:
## ☕ FAQ & Support ## ☕ FAQ & Support
> If you want to support this project, you can search **Tencent Charity** on WeChat and donate to **Education Support Programs** as you wish~ > If you want to support this project, you can search **Tencent Charity** on WeChat and donate to **Education Support Programs** as you wish
> >
> We're anxious about information overload, while they struggle in information deserts without even learning opportunities, so they need support more than me. > Thanks to those who participated in the **one-yuan donation**! You are listed in the **Acknowledgments** at the top. Your support gives more motivation to open source maintenance. Personal donation QR code has been removed.
<details>
<summary><b>👉 Click to expand: Author's Note</b></summary>
<br>
Thanks for all support! Due to 302.AI sponsorship, my personal **one-yuan donation** QR code has been removed.
Previous **one-yuan supporters** are listed in the **Acknowledgments** section at the top.
This project's development and maintenance require significant time, effort, and costs (including AI model fees). With sponsorship support, I can maintain it more confidently.
Currently, major AI model prices are relatively affordable. Welcome to register and try, you can **[click here to claim $1 free credit](#-sponsors)**.
</details>
- **GitHub Issues**: Suitable for targeted answers. Please provide complete info when asking (screenshots, error logs, system environment, etc.) - **GitHub Issues**: Suitable for targeted answers. Please provide complete info when asking (screenshots, error logs, system environment, etc.)
- **WeChat Official Account**: Suitable for quick consultation. Suggest priority to communicate in public comment area of related articles. If private message, please use polite language 😉 - **WeChat Official Account**: Suitable for quick consultation. Suggest priority to communicate in public comment area of related articles. If private message, please use polite language 😉
- 💡 Deployment successful? Welcome to leave comments and likes on our official account to share your experience~ - 💡 Deployment successful? Come to our official account to share your experience! Your likes and suggestions are the driving force for continuous updates~
<div align="center"> <div align="center">
| WeChat Official Account | | WeChat Official Account |
|:---:| |:---:|
| <img src="_image/weixin.png" width="400" title="Silicon-based Tea Room"/> | | <img src="_image/weixin.png" width="400" title="Silicon Tea Room"/> |
</div> </div>
<br>
---
## 🪄 Sponsors ## 🪄 Sponsors
> **302.AI** is a pay-as-you-go enterprise-level AI resource platform > **302.AI** is a pay-as-you-go enterprise-level AI resource platform
@ -2021,7 +2082,7 @@ A: You can top up as needed, pay-as-you-go. Major AI model prices are now relati
### Project Articles ### Project Articles
> **Related Articles** (Chinese): > **4 Related Articles** (Chinese):
- [Comment here for mobile Q&A by project author](https://mp.weixin.qq.com/s/KYEPfTPVzZNWFclZh4am_g) - [Comment here for mobile Q&A by project author](https://mp.weixin.qq.com/s/KYEPfTPVzZNWFclZh4am_g)
- [Breaking 1000 stars in 2 months - My GitHub project promotion experience](https://mp.weixin.qq.com/s/jzn0vLiQFX408opcfpPPxQ) - [Breaking 1000 stars in 2 months - My GitHub project promotion experience](https://mp.weixin.qq.com/s/jzn0vLiQFX408opcfpPPxQ)
@ -2034,7 +2095,7 @@ A: You can top up as needed, pay-as-you-go. Major AI model prices are now relati
- **Core Function**: Quickly filter project code to feed AI, you just need to add personal requirements - **Core Function**: Quickly filter project code to feed AI, you just need to add personal requirements
- **Project Address**: https://github.com/sansan0/ai-code-context-helper - **Project Address**: https://github.com/sansan0/ai-code-context-helper
## ⭐ Related Projects ### Other Projects
> 📍 Chairman Mao's Footprint Map - Interactive dynamic display of complete trajectory 1893-1976. Welcome comrades to contribute data > 📍 Chairman Mao's Footprint Map - Interactive dynamic display of complete trajectory 1893-1976. Welcome comrades to contribute data
@ -2045,21 +2106,6 @@ A: You can top up as needed, pay-as-you-go. Major AI model prices are now relati
- https://github.com/sansan0/bilibili-comment-analyzer - https://github.com/sansan0/bilibili-comment-analyzer
<details>
<summary><strong>👉 Click to expand: WeChat Push Notification Solution</strong></summary>
<br>
> Since this solution is based on WeWork's plugin mechanism and has very different push styles, I temporarily don't plan to include related implementation in the current project
- Fork this user's project: https://github.com/jayzqj/TrendRadar
- Complete WeWork push setup above
- Follow the image below to operate
- After configuration, you can delete WeWork app from your phone
<img src="_image/wework.png" title="github"/>
</details>
### Project Workflow Diagram ### Project Workflow Diagram
```mermaid ```mermaid

258
README.md
View File

@ -13,10 +13,11 @@
[![GitHub Stars](https://img.shields.io/github/stars/sansan0/TrendRadar?style=flat-square&logo=github&color=yellow)](https://github.com/sansan0/TrendRadar/stargazers) [![GitHub Stars](https://img.shields.io/github/stars/sansan0/TrendRadar?style=flat-square&logo=github&color=yellow)](https://github.com/sansan0/TrendRadar/stargazers)
[![GitHub Forks](https://img.shields.io/github/forks/sansan0/TrendRadar?style=flat-square&logo=github&color=blue)](https://github.com/sansan0/TrendRadar/network/members) [![GitHub Forks](https://img.shields.io/github/forks/sansan0/TrendRadar?style=flat-square&logo=github&color=blue)](https://github.com/sansan0/TrendRadar/network/members)
[![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg?style=flat-square)](LICENSE) [![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg?style=flat-square)](LICENSE)
[![Version](https://img.shields.io/badge/version-v3.0.5-blue.svg)](https://github.com/sansan0/TrendRadar) [![Version](https://img.shields.io/badge/version-v3.1.0-blue.svg)](https://github.com/sansan0/TrendRadar)
[![MCP](https://img.shields.io/badge/MCP-v1.0.2-green.svg)](https://github.com/sansan0/TrendRadar) [![MCP](https://img.shields.io/badge/MCP-v1.0.2-green.svg)](https://github.com/sansan0/TrendRadar)
[![企业微信通知](https://img.shields.io/badge/企业微信-通知-00D4AA?style=flat-square)](https://work.weixin.qq.com/) [![企业微信通知](https://img.shields.io/badge/企业微信-通知-00D4AA?style=flat-square)](https://work.weixin.qq.com/)
[![个人微信通知](https://img.shields.io/badge/个人微信-通知-00D4AA?style=flat-square)](https://weixin.qq.com/)
[![Telegram通知](https://img.shields.io/badge/Telegram-通知-00D4AA?style=flat-square)](https://telegram.org/) [![Telegram通知](https://img.shields.io/badge/Telegram-通知-00D4AA?style=flat-square)](https://telegram.org/)
[![dingtalk通知](https://img.shields.io/badge/钉钉-通知-00D4AA?style=flat-square)](#) [![dingtalk通知](https://img.shields.io/badge/钉钉-通知-00D4AA?style=flat-square)](#)
[![飞书通知](https://img.shields.io/badge/飞书-通知-00D4AA?style=flat-square)](https://www.feishu.cn/) [![飞书通知](https://img.shields.io/badge/飞书-通知-00D4AA?style=flat-square)](https://www.feishu.cn/)
@ -314,11 +315,18 @@ GitHub 一键 Fork 即可使用,无需编程基础。
- **大版本升级**:从 v1.x 升级到 v2.y建议删除现有 fork 后重新 fork这样更省力且避免配置冲突 - **大版本升级**:从 v1.x 升级到 v2.y建议删除现有 fork 后重新 fork这样更省力且避免配置冲突
### 2025/11/12 - v3.0.5 ### 2025/11/20 - v3.1.0
- 修复邮件发送 SSL/TLS 端口配置逻辑错误 - **新增个人微信推送支持**:企业微信应用可推送到个人微信,无需安装企业微信 APP
- 优化邮箱服务商QQ/163/126默认使用 465 端口SSL - 支持两种消息格式:`markdown`(企业微信群机器人)和 `text`(个人微信应用)
- **新增 Docker 环境变量支持**:核心配置项(`enable_crawler`、`report_mode`、`push_window` 等)支持通过环境变量覆盖,解决 NAS 用户修改配置文件不生效的问题(详见 [🐳 Docker 部署](#-docker-部署) 章节) - 新增 `WEWORK_MSG_TYPE` 环境变量配置,支持 GitHub Actions、Docker、docker-compose 等多种部署方式
- `text` 模式自动清除 Markdown 语法,提供纯文本推送效果
- 详见快速开始中的「个人微信推送」配置说明
**升级说明**GitHub Fork 用户):
- 必须更新:`main.py`、`config/config.yaml`
- 可选更新:`.github/workflows/crawler.yml`(如使用 GitHub Actions 部署)
- 建议使用小版本升级方式:复制替换上述文件
@ -331,6 +339,13 @@ GitHub 一键 Fork 即可使用,无需编程基础。
<details> <details>
<summary>👉 点击展开:<strong>历史更新</strong></summary> <summary>👉 点击展开:<strong>历史更新</strong></summary>
### 2025/11/12 - v3.0.5
- 修复邮件发送 SSL/TLS 端口配置逻辑错误
- 优化邮箱服务商QQ/163/126默认使用 465 端口SSL
- **新增 Docker 环境变量支持**:核心配置项(`enable_crawler`、`report_mode`、`push_window` 等)支持通过环境变量覆盖,解决 NAS 用户修改配置文件不生效的问题(详见 [🐳 Docker 部署](#-docker-部署) 章节)
### 2025/10/26 - mcp-v1.0.1 ### 2025/10/26 - mcp-v1.0.1
**MCP 模块更新:** **MCP 模块更新:**
@ -651,6 +666,37 @@ frequency_words.txt 文件增加了一个【必须词】功能,使用 + 号
#### PC 端设置流程类似 #### PC 端设置流程类似
</details> </details>
<details>
<summary>👉 点击展开:<strong>个人微信推送</strong>(基于企业微信应用,推送到个人微信)</summary>
<br>
> 由于该方案是基于企业微信的插件机制,推送样式为纯文本(无 markdown 格式),但可以直接推送到个人微信,无需安装企业微信 App。
**GitHub Secret 配置(⚠️ Name 名称必须严格一致):**
- **Name名称**`WEWORK_WEBHOOK_URL`(请复制粘贴此名称,不要手打)
- **Secret**:你的企业微信应用 Webhook 地址
- **Name名称**`WEWORK_MSG_TYPE`(请复制粘贴此名称,不要手打)
- **Secret**`text`
<br>
**设置步骤:**
1. 完成上方的企业微信机器人 Webhook 设置
2. 添加 `WEWORK_MSG_TYPE` Secret值设为 `text`
3. 按照下面图片操作,关联个人微信
4. 配置好后,手机上的企业微信 App 可以删除
<img src="_image/wework.png" title="个人微信推送配置"/>
**说明**
- 与企业微信机器人使用相同的 Webhook 地址
- 区别在于消息格式:`text` 为纯文本,`markdown` 为富文本(默认)
- 纯文本格式会自动去除所有 markdown 语法(粗体、链接等)
</details>
<details> <details>
<summary>👉 点击展开:<strong>飞书机器人</strong>(消息显示最友好)</summary> <summary>👉 点击展开:<strong>飞书机器人</strong>(消息显示最友好)</summary>
<br> <br>
@ -1038,7 +1084,32 @@ frequency_words.txt 文件增加了一个【必须词】功能,使用 + 号
- **关键词设置**:在 [config/frequency_words.txt](config/frequency_words.txt) 中添加你关心的关键词 - **关键词设置**:在 [config/frequency_words.txt](config/frequency_words.txt) 中添加你关心的关键词
- **推送频率调整**:在 [.github/workflows/crawler.yml](.github/workflows/crawler.yml) 请谨慎调整,别贪心 - **推送频率调整**:在 [.github/workflows/crawler.yml](.github/workflows/crawler.yml) 请谨慎调整,别贪心
**注意**:建议只调整文档中明确说明的配置项,其他选项主要供作者开发时测试使用 **注意**:建议只调整文档中明确说明的配置项,其他选项主要供作者开发时测试使用
5. **🎉 部署成功!分享你的使用体验**
恭喜你完成了 TrendRadar 的配置!现在你可以开始追踪热点资讯了。
💬 **有更多小伙伴在公众号交流使用心得,期待你的分享~**
- 想了解更多玩法和高级技巧?
- 遇到问题需要快速解答?
- 有好的想法想要交流?
👉 **欢迎关注公众号「硅基茶水间」**,你的点赞和留言都是项目持续更新的动力。
详细的交流方式,请查看 → [问题答疑与交流](#问题答疑与交流)
6. **想要更智能的分析?试试 AI 增强功能**(可选)
基础配置已经能满足日常使用,但如果你想要:
- 📊 让 AI 自动分析热点趋势和数据洞察
- 🔍 通过自然语言搜索和查询新闻
- 💡 获得情感分析、话题预测等深度分析
- ⚡ 在 Claude、Cursor 等 AI 工具中直接调用数据
👉 **了解更多**[AI 智能分析](#-ai-智能分析) — 解锁项目的隐藏能力,让热点追踪更高效!
## ⚙️ 配置详解 ## ⚙️ 配置详解
@ -1904,89 +1975,6 @@ MCP Inspector 是官方调试工具,用于测试 MCP 连接:
</details> </details>
## ☕问题答疑与交流
> 如果你想支持本项目,可通过微信搜索**腾讯公益**,对里面的**助学计划**随心捐助~
>
> 我还在为信息过载而焦虑,而他们却在信息荒漠中挣扎,他们比我更需要支持。
<details>
<summary>👉 点击展开:<b>作者有话说</b></summary>
<br>
感谢各位支持!因获得[赞助商](#-赞助商)的赞助,现已移除我个人的**一元点赞**打赏码。
之前参与**一元点赞**的朋友已收录至顶部**致谢名单**。
本项目开发和维护投入了大量时间、精力和成本(含 AI 模型费用),有了赞助支持后可以更安心维护。
</details>
- **GitHub Issues**:适合针对性强的解答。提问时请提供完整信息(截图、错误日志、系统环境等)。
- **公众号交流**:适合快速咨询。建议优先在相关文章下的公共留言区交流,如私信,请文明礼貌用语😉
- 💡 部署成功了?欢迎来公众号留言点赞,分享你的使用体验~
<div align="center">
|公众号关注 |
|:---:|
| <img src="_image/weixin.png" width="400" title="硅基茶水间"/> |
</div>
## 🪄 赞助商
> **302.AI** 是按用量付费的企业级 AI 资源平台
> 提供市场上最新、最全面的 **AI 模型**和 **API**,以及多种开箱即用的在线 AI 应用
<div align="center">
<a href="https://share.302.ai/mEOUzG" target="_blank">
<img src="_image/banner-302ai-zh.jpg" alt="302.AI" width="800"/>
</a>
</div>
### 💰 302.AI 新用户福利
> 领取的 1 美元可用于调用各种 AI 大模型(如 Claude、GPT 等)
> 本项目 AI 分析功能需配置大模型使用,配置教程详见 [AI 智能分析](#-ai-智能分析)
[![注册领取](https://img.shields.io/badge/注册_302.AI-领取_1_美元免费测试额度-FF6B6B?style=for-the-badge&logo=openai&logoColor=white)](https://share.302.ai/mEOUzG)
<details id="sponsor-tutorial">
<summary>👉 点击展开:<b>302.AI 使用教程</b></summary>
### 第 1 步:获取 API Key
1. 注册后,进入右上角 [管理后台](https://302.ai/dashboard/overview)
2. 点击左侧 [API Keys](https://302.ai/apis/list)
3. 在页面下方找到默认 API KEY**点击眼睛图标查看**,然后复制
(⚠️ 注意:不是点最右侧的复制按钮)
### 第 2 步:在 Cherry Studio 中配置
1. 打开 Cherry Studio进入设置
2. 模型提供商选择 **"302.AI"**
3. 粘贴刚才复制的 API Key
4. 点击**管理**,现在可以使用所有支持的 AI 模型了
**提示:** Cherry Studio 已原生集成 302.AI配置后即可看到完整模型列表。
**Q: 1 美元免费额度能用多久?**
A: 取决于使用频率和模型选择,可以进行多次测试体验。
**Q: 免费额度用完后怎么办?**
A: 可以按需充值,按量付费。目前大厂模型价格已相对亲民。
</details>
<br>
---
### 常见问题 ### 常见问题
@ -2068,6 +2056,83 @@ A: 可以按需充值,按量付费。目前大厂模型价格已相对亲民
</details> </details>
## ☕问题答疑与交流
> 如果你想支持本项目,可通过微信搜索**腾讯公益**,对里面的**助学**相关的项目随心捐助
>
> 感谢参与过**一元点赞**的朋友,已收录至顶部**致谢名单**!你们的支持让开源维护更有动力,个人打赏码现已移除。
- **GitHub Issues**:适合针对性强的解答。提问时请提供完整信息(截图、错误日志、系统环境等)。
- **公众号交流**:适合快速咨询。建议优先在相关文章下的公共留言区交流,如私信,请文明礼貌用语😉
- 💡 部署成功了?来公众号说说感受吧,你的点赞和留言都是我继续更新的动力~
<div align="center">
|公众号关注 |
|:---:|
| <img src="_image/weixin.png" width="400" title="硅基茶水间"/> |
</div>
<br>
---
## 🪄 赞助商
> **302.AI** 是按用量付费的企业级 AI 资源平台
> 提供市场上最新、最全面的 **AI 模型**和 **API**,以及多种开箱即用的在线 AI 应用
<div align="center">
<a href="https://share.302.ai/mEOUzG" target="_blank">
<img src="_image/banner-302ai-zh.jpg" alt="302.AI" width="800"/>
</a>
</div>
### 💰 302.AI 新用户福利
> 领取的 1 美元可用于调用各种 AI 大模型(如 Claude、GPT 等)
> 本项目 AI 分析功能需配置大模型使用,配置教程详见 [AI 智能分析](#-ai-智能分析)
[![注册领取](https://img.shields.io/badge/注册_302.AI-领取_1_美元免费测试额度-FF6B6B?style=for-the-badge&logo=openai&logoColor=white)](https://share.302.ai/mEOUzG)
<details id="sponsor-tutorial">
<summary>👉 点击展开:<b>302.AI 使用教程</b></summary>
### 第 1 步:获取 API Key
1. 注册后,进入右上角 [管理后台](https://302.ai/dashboard/overview)
2. 点击左侧 [API Keys](https://302.ai/apis/list)
3. 在页面下方找到默认 API KEY**点击眼睛图标查看**,然后复制
(⚠️ 注意:不是点最右侧的复制按钮)
### 第 2 步:在 Cherry Studio 中配置
1. 打开 Cherry Studio进入设置
2. 模型提供商选择 **"302.AI"**
3. 粘贴刚才复制的 API Key
4. 点击**管理**,现在可以使用所有支持的 AI 模型了
**提示:** Cherry Studio 已原生集成 302.AI配置后即可看到完整模型列表。
**Q: 1 美元免费额度能用多久?**
A: 取决于使用频率和模型选择,可以进行多次测试体验。
**Q: 免费额度用完后怎么办?**
A: 可以按需充值,按量付费。目前大厂模型价格已相对亲民。
</details>
---
<br>
### 项目相关 ### 项目相关
> **4 篇文章** > **4 篇文章**
@ -2094,21 +2159,6 @@ A: 可以按需充值,按量付费。目前大厂模型价格已相对亲民
- https://github.com/sansan0/bilibili-comment-analyzer - https://github.com/sansan0/bilibili-comment-analyzer
<details>
<summary>👉 点击展开:<strong>微信推送通知方案</strong></summary>
<br>
> 由于该方案是基于企业微信的插件机制,推送样式也十分不同,所以相关实现我暂时不准备纳入当前项目
- fork 这位兄台的项目 https://github.com/jayzqj/TrendRadar
- 完成上方的企业微信推送设置
- 按照下面图片操作
- 配置好后,手机上的企业微信 app 删除掉也没事
<img src="_image/wework.png" title="github"/>
</details>
### 本项目流程图 ### 本项目流程图
```mermaid ```mermaid

View File

@ -51,13 +51,27 @@ notification:
once_per_day: true # 每天在时间窗口内只推送一次,如果 false则窗口内每次执行都推送 once_per_day: true # 每天在时间窗口内只推送一次,如果 false则窗口内每次执行都推送
push_record_retention_days: 7 # 推送记录保留天数 push_record_retention_days: 7 # 推送记录保留天数
# 请务必妥善保管好 webhooks不要公开 # ⚠️⚠️⚠️ 重要安全警告 / IMPORTANT SECURITY WARNING ⚠️⚠️⚠️
# 如果你以 fork 的方式将本项目部署在 GitHub 上,请勿在此填写任何 webhooks而是将 webhooks 填入 GitHub Secret #
# 不然轻则手机上收到奇怪的广告推送,重则存在更严重的安全隐患 # 🔴 请务必妥善保管好 webhooks不要公开!!!
# 🔴 如果你以 fork 的方式将本项目部署在 GitHub 上,请勿在下面填写任何 webhooks
# 🔴 而是将 webhooks 填入 GitHub SecretSettings → Secrets and variables → Actions
# 🔴 否则:
# - 轻则:手机上收到大量垃圾广告推送
# - 重则webhook 被滥用造成严重安全隐患(如恶意消息轰炸、钓鱼链接等)
#
# 🔴 NEVER expose webhooks publicly!!!
# 🔴 If deploying via GitHub fork, DO NOT fill webhooks below
# 🔴 Instead, add them to GitHub Secrets (Settings → Secrets and variables → Actions)
# 🔴 Consequences of exposure:
# - Minor: Spam notifications flooding your devices
# - Severe: Webhook abuse leading to security incidents (malicious messages, phishing links, etc.)
#
webhooks: webhooks:
feishu_url: "" # 飞书机器人的 webhook URL feishu_url: "" # 飞书机器人的 webhook URL
dingtalk_url: "" # 钉钉机器人的 webhook URL dingtalk_url: "" # 钉钉机器人的 webhook URL
wework_url: "" # 企业微信机器人的 webhook URL wework_url: "" # 企业微信机器人的 webhook URL
wework_msg_type: "markdown" # 企业微信消息类型markdown(群机器人) 或 text(个人微信应用)
telegram_bot_token: "" # Telegram Bot Token telegram_bot_token: "" # Telegram Bot Token
telegram_chat_id: "" # Telegram Chat ID telegram_chat_id: "" # Telegram Chat ID
email_from: "" # 发件人邮箱地址 email_from: "" # 发件人邮箱地址

View File

@ -34,6 +34,7 @@ TELEGRAM_BOT_TOKEN=
TELEGRAM_CHAT_ID= TELEGRAM_CHAT_ID=
DINGTALK_WEBHOOK_URL= DINGTALK_WEBHOOK_URL=
WEWORK_WEBHOOK_URL= WEWORK_WEBHOOK_URL=
WEWORK_MSG_TYPE=
EMAIL_FROM= EMAIL_FROM=
EMAIL_PASSWORD= EMAIL_PASSWORD=

View File

@ -28,6 +28,7 @@ services:
- TELEGRAM_CHAT_ID=${TELEGRAM_CHAT_ID:-} - TELEGRAM_CHAT_ID=${TELEGRAM_CHAT_ID:-}
- DINGTALK_WEBHOOK_URL=${DINGTALK_WEBHOOK_URL:-} - DINGTALK_WEBHOOK_URL=${DINGTALK_WEBHOOK_URL:-}
- WEWORK_WEBHOOK_URL=${WEWORK_WEBHOOK_URL:-} - WEWORK_WEBHOOK_URL=${WEWORK_WEBHOOK_URL:-}
- WEWORK_MSG_TYPE=${WEWORK_MSG_TYPE:-}
# 邮件配置 # 邮件配置
- EMAIL_FROM=${EMAIL_FROM:-} - EMAIL_FROM=${EMAIL_FROM:-}
- EMAIL_PASSWORD=${EMAIL_PASSWORD:-} - EMAIL_PASSWORD=${EMAIL_PASSWORD:-}

View File

@ -26,6 +26,7 @@ services:
- TELEGRAM_CHAT_ID=${TELEGRAM_CHAT_ID:-} - TELEGRAM_CHAT_ID=${TELEGRAM_CHAT_ID:-}
- DINGTALK_WEBHOOK_URL=${DINGTALK_WEBHOOK_URL:-} - DINGTALK_WEBHOOK_URL=${DINGTALK_WEBHOOK_URL:-}
- WEWORK_WEBHOOK_URL=${WEWORK_WEBHOOK_URL:-} - WEWORK_WEBHOOK_URL=${WEWORK_WEBHOOK_URL:-}
- WEWORK_MSG_TYPE=${WEWORK_MSG_TYPE:-}
# 邮件配置 # 邮件配置
- EMAIL_FROM=${EMAIL_FROM:-} - EMAIL_FROM=${EMAIL_FROM:-}
- EMAIL_PASSWORD=${EMAIL_PASSWORD:-} - EMAIL_PASSWORD=${EMAIL_PASSWORD:-}

81
main.py
View File

@ -20,7 +20,7 @@ import requests
import yaml import yaml
VERSION = "3.0.5" VERSION = "3.1.0"
# === SMTP邮件配置 === # === SMTP邮件配置 ===
@ -144,6 +144,9 @@ def load_config():
config["WEWORK_WEBHOOK_URL"] = os.environ.get( config["WEWORK_WEBHOOK_URL"] = os.environ.get(
"WEWORK_WEBHOOK_URL", "" "WEWORK_WEBHOOK_URL", ""
).strip() or webhooks.get("wework_url", "") ).strip() or webhooks.get("wework_url", "")
config["WEWORK_MSG_TYPE"] = os.environ.get(
"WEWORK_MSG_TYPE", ""
).strip() or webhooks.get("wework_msg_type", "markdown")
config["TELEGRAM_BOT_TOKEN"] = os.environ.get( config["TELEGRAM_BOT_TOKEN"] = os.environ.get(
"TELEGRAM_BOT_TOKEN", "" "TELEGRAM_BOT_TOKEN", ""
).strip() or webhooks.get("telegram_bot_token", "") ).strip() or webhooks.get("telegram_bot_token", "")
@ -3583,6 +3586,50 @@ def send_to_dingtalk(
return True return True
def strip_markdown(text: str) -> str:
"""去除文本中的 markdown 语法格式,用于个人微信推送"""
# 去除粗体 **text** 或 __text__
text = re.sub(r'\*\*(.+?)\*\*', r'\1', text)
text = re.sub(r'__(.+?)__', r'\1', text)
# 去除斜体 *text* 或 _text_
text = re.sub(r'\*(.+?)\*', r'\1', text)
text = re.sub(r'_(.+?)_', r'\1', text)
# 去除删除线 ~~text~~
text = re.sub(r'~~(.+?)~~', r'\1', text)
# 转换链接 [text](url) -> text url保留 URL
text = re.sub(r'\[([^\]]+)\]\(([^)]+)\)', r'\1 \2', text)
# 如果不需要保留 URL可以使用下面这行只保留标题文本
# text = re.sub(r'\[([^\]]+)\]\([^)]+\)', r'\1', text)
# 去除图片 ![alt](url) -> alt
text = re.sub(r'!\[(.+?)\]\(.+?\)', r'\1', text)
# 去除行内代码 `code`
text = re.sub(r'`(.+?)`', r'\1', text)
# 去除引用符号 >
text = re.sub(r'^>\s*', '', text, flags=re.MULTILINE)
# 去除标题符号 # ## ### 等
text = re.sub(r'^#+\s*', '', text, flags=re.MULTILINE)
# 去除水平分割线 --- 或 ***
text = re.sub(r'^[\-\*]{3,}\s*$', '', text, flags=re.MULTILINE)
# 去除 HTML 标签 <font color='xxx'>text</font> -> text
text = re.sub(r'<font[^>]*>(.+?)</font>', r'\1', text)
text = re.sub(r'<[^>]+>', '', text)
# 清理多余的空行(保留最多两个连续空行)
text = re.sub(r'\n{3,}', '\n\n', text)
return text.strip()
def send_to_wework( def send_to_wework(
webhook_url: str, webhook_url: str,
report_data: Dict, report_data: Dict,
@ -3591,12 +3638,21 @@ def send_to_wework(
proxy_url: Optional[str] = None, proxy_url: Optional[str] = None,
mode: str = "daily", mode: str = "daily",
) -> bool: ) -> bool:
"""发送到企业微信(支持分批发送""" """发送到企业微信(支持分批发送,支持 markdown 和 text 两种格式"""
headers = {"Content-Type": "application/json"} headers = {"Content-Type": "application/json"}
proxies = None proxies = None
if proxy_url: if proxy_url:
proxies = {"http": proxy_url, "https": proxy_url} proxies = {"http": proxy_url, "https": proxy_url}
# 获取消息类型配置markdown 或 text
msg_type = CONFIG.get("WEWORK_MSG_TYPE", "markdown").lower()
is_text_mode = msg_type == "text"
if is_text_mode:
print(f"企业微信使用 text 格式(个人微信模式)[{report_type}]")
else:
print(f"企业微信使用 markdown 格式(群机器人模式)[{report_type}]")
# 获取分批内容 # 获取分批内容
batches = split_content_into_batches(report_data, "wework", update_info, mode=mode) batches = split_content_into_batches(report_data, "wework", update_info, mode=mode)
@ -3604,17 +3660,28 @@ def send_to_wework(
# 逐批发送 # 逐批发送
for i, batch_content in enumerate(batches, 1): for i, batch_content in enumerate(batches, 1):
batch_size = len(batch_content.encode("utf-8"))
print(
f"发送企业微信第 {i}/{len(batches)} 批次,大小:{batch_size} 字节 [{report_type}]"
)
# 添加批次标识 # 添加批次标识
if len(batches) > 1: if len(batches) > 1:
if is_text_mode:
batch_header = f"[第 {i}/{len(batches)} 批次]\n\n"
else:
batch_header = f"**[第 {i}/{len(batches)} 批次]**\n\n" batch_header = f"**[第 {i}/{len(batches)} 批次]**\n\n"
batch_content = batch_header + batch_content batch_content = batch_header + batch_content
# 根据消息类型构建 payload
if is_text_mode:
# text 格式:去除 markdown 语法
plain_content = strip_markdown(batch_content)
payload = {"msgtype": "text", "text": {"content": plain_content}}
batch_size = len(plain_content.encode("utf-8"))
else:
# markdown 格式:保持原样
payload = {"msgtype": "markdown", "markdown": {"content": batch_content}} payload = {"msgtype": "markdown", "markdown": {"content": batch_content}}
batch_size = len(batch_content.encode("utf-8"))
print(
f"发送企业微信第 {i}/{len(batches)} 批次,大小:{batch_size} 字节 [{report_type}]"
)
try: try:
response = requests.post( response = requests.post(

View File

@ -1 +1 @@
3.0.5 3.1.0