测试jobs
This commit is contained in:
54
main.py
54
main.py
@@ -50,7 +50,7 @@ def main():
|
|||||||
else:
|
else:
|
||||||
robot.LOG.error("wechat_ipad客户端启动失败")
|
robot.LOG.error("wechat_ipad客户端启动失败")
|
||||||
# 注册定时任务
|
# 注册定时任务
|
||||||
# jobs(robot)
|
jobs(robot)
|
||||||
# 启动Dashboard服务器
|
# 启动Dashboard服务器
|
||||||
dashboard_server = None
|
dashboard_server = None
|
||||||
try:
|
try:
|
||||||
@@ -70,29 +70,35 @@ def main():
|
|||||||
robot.keep_running_and_block_process()
|
robot.keep_running_and_block_process()
|
||||||
|
|
||||||
|
|
||||||
# def jobs(robot: Robot):
|
def jobs(robot: Robot):
|
||||||
# # # 每天 8:30 发送新闻
|
# # 每天 8:30 发送新闻
|
||||||
# robot.onEveryTime("08:30", robot.news_baidu_report_auto)
|
@async_job.at_times(["08:30"])
|
||||||
# #
|
async def news_baidu_report_auto_job():
|
||||||
# # # epic
|
await robot.news_baidu_report_auto()
|
||||||
# robot.onEveryTime("10:30", robot.send_epic_free_games)
|
|
||||||
# #
|
@async_job.at_times(["10:36"])
|
||||||
# # # message report 1:数据自动从redis 转到sqllite
|
async def test_job():
|
||||||
# robot.onEveryTime("02:30", robot.message_count_to_db)
|
await robot.job_test()
|
||||||
# # # 从db中提取并发送给相关群
|
# #
|
||||||
# robot.onEveryTime("09:30", robot.generate_and_send_ranking)
|
# # # epic
|
||||||
# #
|
# robot.onEveryTime("10:30", robot.send_epic_free_games)
|
||||||
# # # sehuatang
|
# #
|
||||||
# robot.onEveryTime("15:30", robot.generate_sehuatang_pdf)
|
# # # message report 1:数据自动从redis 转到sqllite
|
||||||
# #
|
# robot.onEveryTime("02:30", robot.message_count_to_db)
|
||||||
# # # 秀人网每天自动下载帖子
|
# # # 从db中提取并发送给相关群
|
||||||
# robot.onEveryTime("01:30", robot.xiu_ren_download_task)
|
# robot.onEveryTime("09:30", robot.generate_and_send_ranking)
|
||||||
# #
|
# #
|
||||||
# # # 秀人网每天自动发pdf
|
# # # sehuatang
|
||||||
# # robot.onEveryTime("17:30", robot.xiu_ren_pdf_send)
|
# robot.onEveryTime("15:30", robot.generate_sehuatang_pdf)
|
||||||
#
|
# #
|
||||||
# # 每天进行二次登录检查
|
# # # 秀人网每天自动下载帖子
|
||||||
# robot.onEveryHours(3, robot.login_twice_auto_auth)
|
# 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__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
123
robot.py
123
robot.py
@@ -631,73 +631,72 @@ class Robot:
|
|||||||
self.LOG.error(f"login_twice_auto_auth error: {e}")
|
self.LOG.error(f"login_twice_auto_auth error: {e}")
|
||||||
|
|
||||||
# ============================================== 业务内容==========================================================
|
# ============================================== 业务内容==========================================================
|
||||||
def set_jobs(self):
|
|
||||||
@async_job.at_times(["08:30"])
|
|
||||||
async def news_baidu_report_auto() -> None:
|
|
||||||
try:
|
|
||||||
news = News().get_baidu_news()
|
|
||||||
await self.send_group_txt_message(news, Feature.DAILY_NEWS)
|
|
||||||
except Exception as e:
|
|
||||||
self.LOG.error(f"newsBaiduReportAuto error:{e}")
|
|
||||||
|
|
||||||
async def news_en_report(website, sender: str = None) -> None:
|
|
||||||
try:
|
|
||||||
news = News().get_eng_news(website)
|
|
||||||
await self.ipad_bot.send_text_message(sender, news)
|
|
||||||
except Exception as e:
|
|
||||||
self.LOG.error(f"newsEnReport error:{e}")
|
|
||||||
|
|
||||||
# 使用装饰器标记定时任务 星期五 10:30 执行
|
async def news_baidu_report_auto(self) -> None:
|
||||||
|
try:
|
||||||
|
news = News().get_baidu_news()
|
||||||
|
await self.send_group_txt_message(news, Feature.DAILY_NEWS)
|
||||||
|
except Exception as e:
|
||||||
|
self.LOG.error(f"newsBaiduReportAuto error:{e}")
|
||||||
|
|
||||||
@async_job.every_weekday_time(weekday=4, time_str="10:00") # 0=周一,4=周五
|
async def news_en_report(self, website, sender: str = None) -> None:
|
||||||
async def send_epic_free_games():
|
try:
|
||||||
try:
|
news = News().get_eng_news(website)
|
||||||
if is_friday():
|
await self.ipad_bot.send_text_message(sender, news)
|
||||||
games = get_free()
|
except Exception as e:
|
||||||
await self.send_group_txt_message(games, Feature.EPIC)
|
self.LOG.error(f"newsEnReport error:{e}")
|
||||||
except Exception as e:
|
|
||||||
self.LOG.error(f"sendEpicFreeGames error:{e}")
|
|
||||||
|
|
||||||
# 使用装饰器标记定时任务
|
# 使用装饰器标记定时任务 星期五 10:30 执行
|
||||||
@async_job.at_times(["02:30"])
|
|
||||||
async def message_count_to_db():
|
|
||||||
try:
|
|
||||||
self.message_storage.write_to_db()
|
|
||||||
except Exception as e:
|
|
||||||
self.LOG.error(f"write_to_db error:{e}")
|
|
||||||
|
|
||||||
@async_job.at_times(["15:30"])
|
@async_job.every_weekday_time(weekday=4, time_str="10:00") # 0=周一,4=周五
|
||||||
async def generate_sehuatang_pdf():
|
async def send_epic_free_games(self):
|
||||||
try:
|
try:
|
||||||
self.LOG.info("开始生成PDF,generate_sehuatang_pdf")
|
if is_friday():
|
||||||
path = pdf_file_path()
|
games = get_free()
|
||||||
# 暂时只发4K群
|
await self.send_group_txt_message(games, Feature.EPIC)
|
||||||
await self.send_group_file_message(path, Feature.PDF_CAPABILITY)
|
except Exception as e:
|
||||||
except Exception as e:
|
self.LOG.error(f"sendEpicFreeGames error:{e}")
|
||||||
self.LOG.error(f"generateSehuatangPdf error:{e}")
|
|
||||||
|
|
||||||
@async_job.at_times(["01:30"])
|
# 使用装饰器标记定时任务
|
||||||
async def xiu_ren_download_task():
|
@async_job.at_times(["02:30"])
|
||||||
try:
|
async def message_count_to_db(self):
|
||||||
# 每天下载10组图,然后发一个帖子PDF
|
try:
|
||||||
meitu_dowload_pub_pic()
|
self.message_storage.write_to_db()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.LOG.error(f"xiu_ren_download_task error:{e}")
|
self.LOG.error(f"write_to_db error:{e}")
|
||||||
|
|
||||||
@async_job.at_times(["09:30"])
|
@async_job.at_times(["15:30"])
|
||||||
async def generate_and_send_ranking():
|
async def generate_sehuatang_pdf(self):
|
||||||
try:
|
try:
|
||||||
receivers = self.gbm.get_group_list()
|
self.LOG.info("开始生成PDF,generate_sehuatang_pdf")
|
||||||
if not receivers:
|
path = pdf_file_path()
|
||||||
return
|
# 暂时只发4K群
|
||||||
for r in receivers:
|
await self.send_group_file_message(path, Feature.PDF_CAPABILITY)
|
||||||
if self.gbm.get_group_permission(r, Feature.DAILY_SUMMARY) == PermissionStatus.ENABLED:
|
except Exception as e:
|
||||||
output = self.message_storage.generate_and_send_ranking(r, self.allContacts)
|
self.LOG.error(f"generateSehuatangPdf error:{e}")
|
||||||
await self.ipad_bot.send_text_message(r, output)
|
|
||||||
except Exception as e:
|
|
||||||
self.LOG.error(f"SendRanking error:{e}")
|
|
||||||
|
|
||||||
@async_job.at_times(["10:30"])
|
@async_job.at_times(["01:30"])
|
||||||
async def job_test():
|
async def xiu_ren_download_task(self):
|
||||||
self.LOG.info("执行测试任务!")
|
try:
|
||||||
await self.ipad_bot.send_text_message("Jyunere","测试任务!")
|
# 每天下载10组图,然后发一个帖子PDF
|
||||||
|
meitu_dowload_pub_pic()
|
||||||
|
except Exception as e:
|
||||||
|
self.LOG.error(f"xiu_ren_download_task error:{e}")
|
||||||
|
|
||||||
|
@async_job.at_times(["09:30"])
|
||||||
|
async def generate_and_send_ranking(self):
|
||||||
|
try:
|
||||||
|
receivers = self.gbm.get_group_list()
|
||||||
|
if not receivers:
|
||||||
|
return
|
||||||
|
for r in receivers:
|
||||||
|
if self.gbm.get_group_permission(r, Feature.DAILY_SUMMARY) == PermissionStatus.ENABLED:
|
||||||
|
output = self.message_storage.generate_and_send_ranking(r, self.allContacts)
|
||||||
|
await self.ipad_bot.send_text_message(r, output)
|
||||||
|
except Exception as e:
|
||||||
|
self.LOG.error(f"SendRanking error:{e}")
|
||||||
|
|
||||||
|
@async_job.at_times(["10:23"])
|
||||||
|
async def job_test(self):
|
||||||
|
await self.ipad_bot.send_text_message("Jyunere","测试任务!")
|
||||||
Reference in New Issue
Block a user