This commit is contained in:
MasonLiu 2024-12-18 11:56:11 +08:00
parent 87f8e3d3de
commit 223fcfc50c
14 changed files with 148 additions and 83 deletions

75
Core.py
View File

@ -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源状态

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -30,9 +30,10 @@ web运行`python ./web/app.py` <br>
<center><img src="./imgs/bot_config.jpg" width="50%" alt="机器人配置"/></center><br>
再之后将配置信息填入config.yaml文件当中 <br>
<center><img src="./imgs/config.jpg" alt="配置"/></center><br>
那么选择,您就可以开始运行使用了。 <br>
那么现在,您就可以开始运行使用了。 <br>
### 运行结果 <br>
![飞书展示](./imgs/start.jpg) <br>
![后端展示](./imgs/run.jpg) <br>
<center><img src="./imgs/start.jpg" width="50%" alt="飞书运行提示"/></center><br>
<center><img src="./imgs/result.jpg" width="50%" alt="飞书运行展示"/></center><br>
<center><img src="./imgs/run.jpg" width="50%" alt="后端"/></center><br>

View File

@ -2,6 +2,7 @@
### 问题反馈 <br>
- 准点发送的文章在定点推送模式下可能会被遗漏推送 <br>
- 钉钉/企业微信/蓝信webhook存在字节长度限制需要优化程序推送逻辑 <br>
### 下一步计划 <br>
- 添加更多RSS订阅源持续进行中 <br>
@ -15,4 +16,5 @@
### 更新日志
- 2024年12月15日早优化了文件结构修复了日志记录时的小BUG添加web展示日志功能 <br>
- 2024年12月15日晚修复了单次运行结束时的校验错误问题 <br>
- 2024年12月15日晚修复了单次运行结束时的校验错误问题 <br>
- 2024年12月18日早添加了短文本推送机制一定程度上解决了长字节推送问题 <br>

View File

@ -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 #用户名

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

After

Width:  |  Height:  |  Size: 275 KiB

BIN
imgs/result.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB