# notes_to_blog_server **Repository Path**: mdashen_com/notes_to_blog ## Basic Information - **Project Name**: notes_to_blog_server - **Description**: 微信群内容同步到博客页面 - **Primary Language**: NodeJS - **License**: MIT - **Default Branch**: master - **Homepage**: https://blog.mdashen.com/notes/ - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-07-16 - **Last Updated**: 2025-04-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 业务逻辑 监听特定微信群中的消息,同步到博客页面上。 用于日常的一些 语句\图片 摘抄。备份和展示作用。 ## bug 微信表情暂时无法处理。 影响不大,大家看文字脑部表情吧。。。。[笑] ## 使用方法 项目生成的 md 文档路径:src/public/md/index.md 监听特定微信群配置:src/conf/listenGroup.js 数据库配置 Mysql:src/conf/db.js 相关路径配置:src/conf/path.js 同步数据库结构:`npm run sync` 微信群中有新消息时,会将消息内容push到数据表中,生成新的 src/public/md/index.md 文件。 同时在服务器中设置定时任务,将项目生成的 md 文档,复制到 博客 特定目录。并重新静态化md文件,生成静态html文件。 我使用的是 hexo。 定时任务,根据你自己的消息频率设定就好。 ![image-20230813180800147](https://image.mdashen.com/pic/20230813180805.png) ```sh #!/bin/bash updateBlog(){ cp /www/wwwroot/notes.mdashen.com/src/public/md/index.md /www/wwwroot/mdashen.com/source/notes/ chown -R www:www /www/wwwroot/mdashen.com/source/notes/index.md cd /www/wwwroot/mdashen.com/ npm run generate echo "更新blog成功" } # 获取当前时间戳 timestamp=$(date +%s) # 获取文件修改时间戳 fileUpdateTimestamp=$(stat -c %Y /www/wwwroot/notes.mdashen.com/src/public/md/index.md) # 获取两个时间戳的插值是否小于24h if [ $((timestamp - fileUpdateTimestamp)) -lt 86400 ]; then echo "文件更新时间小于24h" updateBlog else echo "文件更新时间大于24h" # 24小时内没有生成新的文件,不需要重新提交blog更新 fi ``` image-20230729144620196 项目部分代码由 chatgpt 生成,未经过严格测试。 ## 本项目使用的部分库 * [json2md](https://www.npmjs.com/package/json2md) * [wechat4u](https://www.npmjs.com/package/wechat4u)