diff --git a/Core.py b/Core.py index e316f11..abbabf0 100644 --- a/Core.py +++ b/Core.py @@ -46,26 +46,38 @@ e_hour = int(f"{config['e_hour']}") choice = int(f"{config['circle']}") fs_activate = f"{config['fs_activate']}" wx_activate = f"{config['wx_activate']}" +ding_activate = f"{config['ding_activate']}" +lx_activate = f"{config['lx_activate']}" webhook_url_once, timestamp_once, sign_once = gen_sign() -def check_avaliable(info, title, webhook_url, timestamp, sign): - if info: - if fs_activate == "True": - # logger.info(f"{title} 递送中(飞书):") - result = SendToFeishu(info, title, webhook_url, timestamp, sign) - logger.info(result) - time.sleep(30) - else: - pass +def check_avaliable(info_long, info_short, title, webhook_url, timestamp, sign): + if info_long: # 发送完整文章相关内容 + # logger.info(f"{title} 递送中(飞书):") + result = SendToFeishu(info_long, title, webhook_url, timestamp, sign) + logger.info(result) + time.sleep(30) + else: + pass + if info_short: # 发送精简文章相关内容 + # 企业微信相关 if wx_activate == "True": # logger.info(f"{title} 递送中(企业微信):") - result = SendToWX(info, title) + result = SendToWX(info_short, title) logger.info(result) time.sleep(30) else: pass - else: + + # 钉钉相关 + if ding_activate == "True": + # logger.info(f"{title} 递送中(钉钉):") + # result = SendToWX(info_short, title) # 待完善 + logger.info(result) + time.sleep(30) + else: + pass + if not info_long and not info_short: logger.info(f"{title}数据为空,跳过执行。") def send_job(time_1): @@ -81,24 +93,34 @@ def send_job(time_1): xianzhi_main() M_4hou_main() - # 分析各个数据源的结果 - reslt_4hou = Src_4hou(time_1) - reslt_anquanke = Src_anquanke(time_1) - reslt_doonsec = Src_doonsec(time_1) - reslt_xianzhi = Src_xianzhi(time_1) - reslt_freebuf = Src_freebuf(time_1) - reslt_qianxin = Src_qianxin(time_1) - reslt_seebug = Src_seebug(time_1) + if fs_activate == "True": + # 分析各个数据源的结果 + result_4hou_long = Src_4hou(time_1, False) + result_anquanke_long = Src_anquanke(time_1, False) + result_doonsec_long = Src_doonsec(time_1, False) + result_xianzhi_long = Src_xianzhi(time_1, False) + result_freebuf_long = Src_freebuf(time_1, False) + result_qianxin_long = Src_qianxin(time_1, False) + result_seebug_long = Src_seebug(time_1, False) + elif wx_activate == "True" or ding_activate == "True" or lx_activate == "True": + # 分析各个数据源的结果 + result_4hou_short = Src_4hou(time_1, True) + result_anquanke_short = Src_anquanke(time_1, True) + result_doonsec_short = Src_doonsec(time_1, True) + result_xianzhi_short = Src_xianzhi(time_1, True) + result_freebuf_short = Src_freebuf(time_1, True) + result_qianxin_short = Src_qianxin(time_1, True) + result_seebug_short = Src_seebug(time_1, True) webhook_url, timestamp, sign = gen_sign() - check_avaliable(reslt_4hou, "嘶吼资讯", webhook_url, timestamp, sign) - check_avaliable(reslt_anquanke, "安全客资讯", webhook_url, timestamp, sign) - check_avaliable(reslt_doonsec, "洞见微信安全资讯", webhook_url, timestamp, sign) - check_avaliable(reslt_xianzhi, "先知社区资讯", webhook_url, timestamp, sign) - check_avaliable(reslt_freebuf, "FreeBuf资讯", webhook_url, timestamp, sign) - check_avaliable(reslt_qianxin, "奇安信攻防社区资讯", webhook_url, timestamp, sign) - check_avaliable(reslt_seebug, "Seebug社区资讯", webhook_url, timestamp, sign) + check_avaliable(result_4hou_long, result_4hou_short, "嘶吼资讯", webhook_url, timestamp, sign) + check_avaliable(result_anquanke_long, result_anquanke_short, "安全客资讯", webhook_url, timestamp, sign) + check_avaliable(result_doonsec_long, result_doonsec_short, "洞见微信安全资讯", webhook_url, timestamp, sign) + check_avaliable(result_xianzhi_long, result_xianzhi_short, "先知社区资讯", webhook_url, timestamp, sign) + check_avaliable(result_freebuf_long, result_freebuf_short, "FreeBuf资讯", webhook_url, timestamp, sign) + check_avaliable(result_qianxin_long, result_qianxin_short, "奇安信攻防社区资讯", webhook_url, timestamp, sign) + check_avaliable(result_seebug_long, result_seebug_short, "Seebug社区资讯", webhook_url, timestamp, sign) if fs_activate == "True": send_result = SendToFeishu("[点此访问](https://info.masonliu.com)网站以查看全部文章。", "单次运行结束", webhook_url, timestamp, sign) @@ -145,7 +167,6 @@ def main_loop(choice): while True: schedule.run_pending() - n += 1 time.sleep(60) # 每分钟检查一次是否有任务需要执行 # 探测rss源状态 diff --git a/GotoSend/M_4hou.py b/GotoSend/M_4hou.py index a5452a8..15d36bc 100644 --- a/GotoSend/M_4hou.py +++ b/GotoSend/M_4hou.py @@ -107,13 +107,18 @@ def record_md(result, filename="./history/sec_news.md"): # 写回文件 with open(filename, 'w', encoding='utf-8') as file: file.write(new_content) -def get_filtered_articles(entries): +def get_filtered_articles(entries, Is_short): result = "" record = "" for entry in entries: - result += f"作者:{entry[5]}\n文章:{entry[1]}\n" - result += f"链接:{entry[2]}\n上传时间:{entry[4]}\n" - result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章 + if Is_short == False: + result += f"作者:{entry[5]}\n文章:{entry[1]}\n" + result += f"链接:{entry[2]}\n上传时间:{entry[4]}\n" + result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章 + if Is_short == True: + result += f"文章:{entry[1]}\n" + result += f"链接:{entry[2]}\n上传时间:{entry[4]}\n" + result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章 record += f"#### 文章:{entry[1]}\n" record += f"**作者**:{entry[5]}\n" @@ -124,7 +129,7 @@ def get_filtered_articles(entries): return result -def Src_4hou(e_hour): +def Src_4hou(e_hour, Is_short): if not os.path.exists('./db/4hou.db'): # 创建数据库和表 create_database() @@ -143,13 +148,13 @@ def Src_4hou(e_hour): # print(filtered_articles) if filtered_articles: - results = get_filtered_articles(filtered_articles) + results = get_filtered_articles(filtered_articles, Is_short) return results else: return "" if __name__ == "__main__": - reslts = Src_4hou(4) + reslts = Src_4hou(4, False) if reslts != "": print(reslts) else: diff --git a/GotoSend/anquanke.py b/GotoSend/anquanke.py index e4c5f6c..8eb8883 100644 --- a/GotoSend/anquanke.py +++ b/GotoSend/anquanke.py @@ -102,13 +102,18 @@ def record_md(result, filename="./history/sec_news.md"): with open(filename, 'w', encoding='utf-8') as file: file.write(new_content) -def get_filtered_articles(entries): +def get_filtered_articles(entries, Is_short): result = "" record = "" for entry in entries: - result += f"作者:{entry[6]}\n来源:{entry[3]}\n文章:{entry[1]}\n" - result += f"链接:{entry[2]}\n上传时间:{entry[5]}\n" - result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章 + if Is_short == False: + result += f"作者:{entry[6]}\n来源:{entry[3]}\n文章:{entry[1]}\n" + result += f"链接:{entry[2]}\n上传时间:{entry[5]}\n" + result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章 + elif Is_short == True: + result += f"文章:{entry[1]}\n" + result += f"链接:{entry[2]}\n上传时间:{entry[5]}\n" + result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章 record += f"#### 文章:{entry[1]}\n" record += f"**作者**:{entry[6]}\n" @@ -120,7 +125,7 @@ def get_filtered_articles(entries): return result -def Src_anquanke(e_hour): +def Src_anquanke(e_hour, Is_short): if not os.path.exists('./db/anquanke.db'): # 创建数据库和表 create_database() @@ -139,13 +144,13 @@ def Src_anquanke(e_hour): # print(filtered_articles) if filtered_articles: - results = get_filtered_articles(filtered_articles) + results = get_filtered_articles(filtered_articles, Is_short) return results else: return False if __name__ == "__main__": - reslts = Src_anquanke(4) + reslts = Src_anquanke(4, False) if reslts != False: print(reslts) else: diff --git a/GotoSend/doonsec.py b/GotoSend/doonsec.py index 92dbeca..4751700 100644 --- a/GotoSend/doonsec.py +++ b/GotoSend/doonsec.py @@ -109,14 +109,19 @@ def record_md(result, filename="./history/tech_passage.md"): with open(filename, 'w', encoding='utf-8') as file: file.write(new_content) -def get_filtered_articles(entries): +def get_filtered_articles(entries, Is_short): result = "" record = "" for entry in entries: - result += f"作者:{entry[5]}\n文章:{entry[1]}\n" - result += f"链接:[点此访问]({entry[2]})\n上传时间:{entry[4]}\n" - result += f"简介:{entry[3]}\n" - result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章 + if Is_short == False: + result += f"作者:{entry[5]}\n文章:{entry[1]}\n" + result += f"链接:[点此访问]({entry[2]})\n上传时间:{entry[4]}\n" + result += f"简介:{entry[3]}\n" + result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章 + if Is_short == True: + result += f"文章:{entry[1]}\n" + result += f"链接:[点此访问]({entry[2]})\n上传时间:{entry[4]}\n" + result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章 record += f"#### 文章:{entry[1]}\n" record += f"**作者**:{entry[5]}\n" @@ -128,7 +133,7 @@ def get_filtered_articles(entries): return result -def Src_doonsec(e_hour): +def Src_doonsec(e_hour, Is_short): if not os.path.exists('./db/doonsec.db'): # 创建数据库和表 create_database() @@ -147,13 +152,13 @@ def Src_doonsec(e_hour): # print(filtered_articles) if filtered_articles: - results = get_filtered_articles(filtered_articles) + results = get_filtered_articles(filtered_articles, Is_short) return results else: return False if __name__ == "__main__": - reslts = Src_doonsec(4) + reslts = Src_doonsec(4, False) if reslts != False: print(reslts) else: diff --git a/GotoSend/freebuf.py b/GotoSend/freebuf.py index dc19647..d97c36c 100644 --- a/GotoSend/freebuf.py +++ b/GotoSend/freebuf.py @@ -108,13 +108,18 @@ def record_md(result, filename="./history/sec_news.md"): with open(filename, 'w', encoding='utf-8') as file: file.write(new_content) -def get_filtered_articles(entries): +def get_filtered_articles(entries, Is_short): result = "" record = "" for entry in entries: - result += f"类型:{entry[5]}\n文章:{entry[1]}\n" - result += f"链接:{entry[2]}\n上传时间:{entry[4]}\n" - result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章 + if Is_short == False: + result += f"类型:{entry[5]}\n文章:{entry[1]}\n" + result += f"链接:{entry[2]}\n上传时间:{entry[4]}\n" + result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章 + elif Is_short == True: + result += f"文章:{entry[1]}\n" + result += f"链接:{entry[2]}\n上传时间:{entry[4]}\n" + result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章 record += f"#### 文章:{entry[1]}\n" record += f"**类型**:{entry[5]}\n" @@ -125,7 +130,7 @@ def get_filtered_articles(entries): return result -def Src_freebuf(e_hour): +def Src_freebuf(e_hour, Is_short): if not os.path.exists('./db/freebuf.db'): # 创建数据库和表 create_database() @@ -144,13 +149,13 @@ def Src_freebuf(e_hour): # print(filtered_articles) if filtered_articles: - results = get_filtered_articles(filtered_articles) + results = get_filtered_articles(filtered_articles, Is_short) return results else: return False if __name__ == "__main__": - reslts = Src_freebuf(4) + reslts = Src_freebuf(4, False) if reslts != False: print(reslts) else: diff --git a/GotoSend/qianxin.py b/GotoSend/qianxin.py index 350fc64..9f89757 100644 --- a/GotoSend/qianxin.py +++ b/GotoSend/qianxin.py @@ -99,14 +99,19 @@ def record_md(result, filename="./history/tech_passage.md"): with open(filename, 'w', encoding='utf-8') as file: file.write(new_content) -def get_filtered_articles(entries): +def get_filtered_articles(entries, Is_short): result = "" record = "" for entry in entries: - result += f"来源:{entry[3]}\n文章:{entry[1]}\n" - result += f"链接:{entry[2]}\n上传时间:{entry[5]}\n" - result += f"描述:{entry[4]}\n" - result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章 + if Is_short == False: + result += f"来源:{entry[3]}\n文章:{entry[1]}\n" + result += f"链接:{entry[2]}\n上传时间:{entry[5]}\n" + result += f"描述:{entry[4]}\n" + result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章 + if Is_short == False: + result += f"文章:{entry[1]}\n" + result += f"链接:{entry[2]}\n上传时间:{entry[5]}\n" + result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章 record += f"#### 文章:{entry[1]}\n" record += f"**来源**:{entry[3]}\n" @@ -118,7 +123,7 @@ def get_filtered_articles(entries): return result -def Src_qianxin(e_hour): +def Src_qianxin(e_hour, Is_short): if not os.path.exists('./db/qianxin.db'): # 创建数据库和表 create_database() @@ -137,13 +142,13 @@ def Src_qianxin(e_hour): # print(filtered_articles) if filtered_articles: - results = get_filtered_articles(filtered_articles) + results = get_filtered_articles(filtered_articles, Is_short) return results else: return False if __name__ == "__main__": - reslts = Src_qianxin(4) + reslts = Src_qianxin(4, False) if reslts != False: print(reslts) else: diff --git a/GotoSend/seebug.py b/GotoSend/seebug.py index a1d9335..86f9449 100644 --- a/GotoSend/seebug.py +++ b/GotoSend/seebug.py @@ -106,14 +106,19 @@ def record_md(result, filename="./history/sec_news.md"): with open(filename, 'w', encoding='utf-8') as file: file.write(new_content) -def get_filtered_articles(entries): +def get_filtered_articles(entries, Is_short): result = "" record = "" for entry in entries: - result += f"类型:{entry[3]}\n文章:{entry[1]}" - result += f"链接:{entry[2]}\n上传时间:{entry[5]}\n" - result += f"{entry[4]}\n" - result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章 + if Is_short == False: + result += f"类型:{entry[3]}\n文章:{entry[1]}" + result += f"链接:{entry[2]}\n上传时间:{entry[5]}\n" + result += f"{entry[4]}\n" + result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章 + if Is_short == True: + result += f"文章:{entry[1]}" + result += f"链接:{entry[2]}\n上传时间:{entry[5]}\n" + result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章 record += f"#### 文章:{entry[1]}\n" record += f"**类型**:{entry[3]}\n" @@ -125,7 +130,7 @@ def get_filtered_articles(entries): return result -def Src_seebug(e_hour): +def Src_seebug(e_hour, Is_short): if not os.path.exists('./db/seebug.db'): # 创建数据库和表 create_database() @@ -144,13 +149,13 @@ def Src_seebug(e_hour): # print(filtered_articles) if filtered_articles: - results = get_filtered_articles(filtered_articles) + results = get_filtered_articles(filtered_articles, Is_short) return results else: return False if __name__ == "__main__": - reslts = Src_seebug(100) + reslts = Src_seebug(100, False) if reslts != False: print(reslts) else: diff --git a/GotoSend/xianzhi.py b/GotoSend/xianzhi.py index cb5c914..807be47 100644 --- a/GotoSend/xianzhi.py +++ b/GotoSend/xianzhi.py @@ -105,13 +105,18 @@ def record_md(result, filename="./history/tech_passage.md"): with open(filename, 'w', encoding='utf-8') as file: file.write(new_content) -def get_filtered_articles(entries): +def get_filtered_articles(entries, Is_short): result = "" record = "" for entry in entries: - result += f"文章:{entry[1]}\n" - result += f"链接:{entry[2]}\n上传时间:{entry[3]}\n" - result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章 + if Is_short == False: + result += f"文章:{entry[1]}\n" + result += f"链接:{entry[2]}\n上传时间:{entry[3]}\n" + result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章 + if Is_short == False: + result += f"文章:{entry[1]}\n" + result += f"链接:{entry[2]}\n上传时间:{entry[3]}\n" + result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章 record += f"#### 文章:{entry[1]}\n" record += f"**链接**:{entry[2]}\n" @@ -121,7 +126,7 @@ def get_filtered_articles(entries): return result -def Src_xianzhi(e_hour): +def Src_xianzhi(e_hour, Is_short): if not os.path.exists('./db/xianzhi.db'): # 创建数据库和表 create_database() @@ -140,13 +145,13 @@ def Src_xianzhi(e_hour): # print(filtered_articles) if filtered_articles: - results = get_filtered_articles(filtered_articles) + results = get_filtered_articles(filtered_articles, Is_short) return results else: return False if __name__ == "__main__": - reslts = Src_xianzhi(4) + reslts = Src_xianzhi(4, False) if reslts != False: print(reslts) else: diff --git a/README.md b/README.md index 9dc138a..58ce332 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,10 @@ web运行:`python ./web/app.py`
机器人配置

再之后,将配置信息填入config.yaml文件当中
配置

-那么选择,您就可以开始运行使用了。
+那么现在,您就可以开始运行使用了。
### 运行结果
-![飞书展示](./imgs/start.jpg)
-![后端展示](./imgs/run.jpg)
+
飞书运行提示

+
飞书运行展示

+
后端

diff --git a/UpdateLOG.md b/UpdateLOG.md index 3100450..437145c 100644 --- a/UpdateLOG.md +++ b/UpdateLOG.md @@ -2,6 +2,7 @@ ### 问题反馈
- 准点发送的文章在定点推送模式下可能会被遗漏推送
+- 钉钉/企业微信/蓝信webhook存在字节长度限制,需要优化程序推送逻辑
### 下一步计划
- 添加更多RSS订阅源(持续进行中)
@@ -15,4 +16,5 @@ ### 更新日志 - 2024年12月15日早:优化了文件结构,修复了日志记录时的小BUG,添加web展示日志功能
-- 2024年12月15日晚:修复了单次运行结束时的校验错误问题
\ No newline at end of file +- 2024年12月15日晚:修复了单次运行结束时的校验错误问题
+- 2024年12月18日早:添加了短文本推送机制,一定程度上解决了长字节推送问题
\ No newline at end of file diff --git a/config.yaml b/config.yaml index d9585eb..a61d0d0 100644 --- a/config.yaml +++ b/config.yaml @@ -7,6 +7,12 @@ fs_secret: 4tq65T4jm1MO2IlxvHxBWe wx_activate: False wx_key: 9a3dd6ff-75d6-4208-bc4b-77724a5805d6 +# 钉钉相关配置信息 +ding_activate: False + +# 蓝信相关配置信息 +lx_activate: False + # 邮件配置 mail_host: smtp.masonliu.com #设置服务器 mail_user: test@masonliu.com #用户名 diff --git a/imgs/config.jpg b/imgs/config.jpg index 72d3ec5..0e24d74 100644 Binary files a/imgs/config.jpg and b/imgs/config.jpg differ diff --git a/imgs/group.jpg b/imgs/group.jpg index 6cbd970..28e4175 100644 Binary files a/imgs/group.jpg and b/imgs/group.jpg differ diff --git a/imgs/result.jpg b/imgs/result.jpg new file mode 100644 index 0000000..2800c13 Binary files /dev/null and b/imgs/result.jpg differ