PyBot/Core.py

46 lines
1.3 KiB
Python
Raw Normal View History

2024-12-03 00:03:14 +08:00
import signal
from datetime import datetime
import sys
import time
from SendBot import SendToFeishu, gen_sign
from media.common import run
from media.freebuf import freebuf_main
from media.xianzhi import xianzhi_main
webhook_url, timestamp, sign = gen_sign()
def crab_job():
print("正在启动各爬虫并获取资源中...")
run()
xianzhi_main()
freebuf_main()
def signal_handler(sig, frame):
print("接收到退出信号,程序即将退出...")
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler) # Ctrl+C
signal.signal(signal.SIGTERM, signal_handler) # kill命令
def main_loop():
while True:
try:
# 获取当前时间
now = datetime.now()
# 检查是否为特定时间点
if now.hour == 17 and now.minute == 25:
crab_job()
print("执行完毕,等待下一次执行...")
else:
print("正在等待执行...")
time.sleep(35) # 每隔35秒执行一次
except Exception as e:
print(f"发生错误: {e}")
msg = {"msg_type":"text","timestamp": f"{timestamp}","sign": f"{sign}","content":{"text":f"发生错误: {e} ,程序已暂停"}}
print(msg)
# SendToFeishu(msg)
exit()
if __name__ == "__main__":
main_loop()