使用异步任务注解

This commit is contained in:
liuwei
2025-05-20 10:21:39 +08:00
parent 628082c93a
commit b44b527346
3 changed files with 137 additions and 49 deletions

54
main.py
View File

@@ -1,6 +1,9 @@
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import asyncio
import threading
from async_job import async_job
from configuration import Config
from robot import Robot
@@ -46,29 +49,8 @@ def main():
robot.LOG.info("wechat_ipad客户端启动成功")
else:
robot.LOG.error("wechat_ipad客户端启动失败")
# # 每天 8:30 发送新闻
robot.onEveryTime("08:30", robot.news_baidu_report_auto)
#
# # epic
robot.onEveryTime("10:30", robot.send_epic_free_games)
#
# # message report 1:数据自动从redis 转到sqllite
robot.onEveryTime("02:30", robot.message_count_to_db)
# # 从db中提取并发送给相关群
robot.onEveryTime("09:30", robot.generate_and_send_ranking)
#
# # sehuatang
robot.onEveryTime("15:30", robot.generate_sehuatang_pdf)
#
# # 秀人网每天自动下载帖子
robot.onEveryTime("01:30", robot.xiu_ren_download_task)
#
# # 秀人网每天自动发pdf
# robot.onEveryTime("17:30", robot.xiu_ren_pdf_send)
# 每天进行二次登录检查
robot.onEveryHours(3, robot.login_twice_auto_auth)
# 注册定时任务
# jobs(robot)
# 启动Dashboard服务器
dashboard_server = None
try:
@@ -83,9 +65,35 @@ def main():
except Exception as e:
robot.LOG.error(f"Dashboard服务器启动失败: {e}")
asyncio.run(async_job.run_all())
# 让机器人一直跑
robot.keep_running_and_block_process()
# def jobs(robot: Robot):
# # # 每天 8:30 发送新闻
# robot.onEveryTime("08:30", robot.news_baidu_report_auto)
# #
# # # epic
# robot.onEveryTime("10:30", robot.send_epic_free_games)
# #
# # # message report 1:数据自动从redis 转到sqllite
# robot.onEveryTime("02:30", robot.message_count_to_db)
# # # 从db中提取并发送给相关群
# robot.onEveryTime("09:30", robot.generate_and_send_ranking)
# #
# # # sehuatang
# robot.onEveryTime("15:30", robot.generate_sehuatang_pdf)
# #
# # # 秀人网每天自动下载帖子
# robot.onEveryTime("01:30", robot.xiu_ren_download_task)
# #
# # # 秀人网每天自动发pdf
# # robot.onEveryTime("17:30", robot.xiu_ren_pdf_send)
#
# # 每天进行二次登录检查
# robot.onEveryHours(3, robot.login_twice_auto_auth)
if __name__ == "__main__":
main()