This commit is contained in:
MasonLiu 2024-12-16 18:57:33 +08:00
parent 4661c90034
commit 87f8e3d3de

15
Core.py
View File

@ -52,14 +52,14 @@ 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} 递送中(飞书):")
# logger.info(f"{title} 递送中(飞书):")
result = SendToFeishu(info, title, webhook_url, timestamp, sign)
logger.info(result)
time.sleep(30)
else:
pass
if fs_activate == "True":
logger.info(f"{title} 递送中(企业微信):")
if wx_activate == "True":
# logger.info(f"{title} 递送中(企业微信):")
result = SendToWX(info, title)
logger.info(result)
time.sleep(30)
@ -70,6 +70,7 @@ def check_avaliable(info, title, webhook_url, timestamp, sign):
def send_job(time_1):
# 爬取数据
logger.info(f"发送程序启动,当前时间为:{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
logger.info("正在启动各爬虫并获取资源中...")
seebug_main()
anquanke_main()
@ -104,7 +105,7 @@ def send_job(time_1):
logger.info(send_result)
else:
pass
if fs_activate == "True":
if wx_activate == "True":
send_result = SendToWX("[点此访问](https://info.masonliu.com)网站以查看全部文章。", "单次运行结束")
logger.info(send_result)
else:
@ -122,12 +123,9 @@ signal.signal(signal.SIGTERM, signal_handler) # kill命令
def main_loop(choice):
if choice == 1:
n = 0
while True:
try:
# 执行任务
n += 1 # 每次循环递增 n
logger.info(f"{n}次执行,当前时间为:{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
send_job(e_hour)
time.sleep(e_hour * 60 * 60 - 3 * 60)
@ -136,10 +134,9 @@ def main_loop(choice):
# result = SendToFeishu(f"发生错误: {e}, 程序已退出", "报错信息")
# logger.info(result)
exit()
elif choice == 0:
n = 0
# 设置每天的特定时间点执行job函数
logger.info(f"{n+1}次执行准备开始。")
schedule.every().day.at("09:00").do(send_job, 12)
schedule.every().day.at("12:00").do(send_job, 3)
schedule.every().day.at("15:00").do(send_job, 3)