测试jobs
This commit is contained in:
14
main.py
14
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,9 +70,15 @@ 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():
|
||||||
|
await robot.news_baidu_report_auto()
|
||||||
|
|
||||||
|
@async_job.at_times(["10:36"])
|
||||||
|
async def test_job():
|
||||||
|
await robot.job_test()
|
||||||
# #
|
# #
|
||||||
# # # epic
|
# # # epic
|
||||||
# robot.onEveryTime("10:30", robot.send_epic_free_games)
|
# robot.onEveryTime("10:30", robot.send_epic_free_games)
|
||||||
|
|||||||
23
robot.py
23
robot.py
@@ -631,16 +631,16 @@ 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:
|
async def news_baidu_report_auto(self) -> None:
|
||||||
try:
|
try:
|
||||||
news = News().get_baidu_news()
|
news = News().get_baidu_news()
|
||||||
await self.send_group_txt_message(news, Feature.DAILY_NEWS)
|
await self.send_group_txt_message(news, Feature.DAILY_NEWS)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.LOG.error(f"newsBaiduReportAuto error:{e}")
|
self.LOG.error(f"newsBaiduReportAuto error:{e}")
|
||||||
|
|
||||||
async def news_en_report(website, sender: str = None) -> None:
|
async def news_en_report(self, website, sender: str = None) -> None:
|
||||||
try:
|
try:
|
||||||
news = News().get_eng_news(website)
|
news = News().get_eng_news(website)
|
||||||
await self.ipad_bot.send_text_message(sender, news)
|
await self.ipad_bot.send_text_message(sender, news)
|
||||||
@@ -650,7 +650,7 @@ class Robot:
|
|||||||
# 使用装饰器标记定时任务 星期五 10:30 执行
|
# 使用装饰器标记定时任务 星期五 10:30 执行
|
||||||
|
|
||||||
@async_job.every_weekday_time(weekday=4, time_str="10:00") # 0=周一,4=周五
|
@async_job.every_weekday_time(weekday=4, time_str="10:00") # 0=周一,4=周五
|
||||||
async def send_epic_free_games():
|
async def send_epic_free_games(self):
|
||||||
try:
|
try:
|
||||||
if is_friday():
|
if is_friday():
|
||||||
games = get_free()
|
games = get_free()
|
||||||
@@ -660,14 +660,14 @@ class Robot:
|
|||||||
|
|
||||||
# 使用装饰器标记定时任务
|
# 使用装饰器标记定时任务
|
||||||
@async_job.at_times(["02:30"])
|
@async_job.at_times(["02:30"])
|
||||||
async def message_count_to_db():
|
async def message_count_to_db(self):
|
||||||
try:
|
try:
|
||||||
self.message_storage.write_to_db()
|
self.message_storage.write_to_db()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.LOG.error(f"write_to_db error:{e}")
|
self.LOG.error(f"write_to_db error:{e}")
|
||||||
|
|
||||||
@async_job.at_times(["15:30"])
|
@async_job.at_times(["15:30"])
|
||||||
async def generate_sehuatang_pdf():
|
async def generate_sehuatang_pdf(self):
|
||||||
try:
|
try:
|
||||||
self.LOG.info("开始生成PDF,generate_sehuatang_pdf")
|
self.LOG.info("开始生成PDF,generate_sehuatang_pdf")
|
||||||
path = pdf_file_path()
|
path = pdf_file_path()
|
||||||
@@ -677,7 +677,7 @@ class Robot:
|
|||||||
self.LOG.error(f"generateSehuatangPdf error:{e}")
|
self.LOG.error(f"generateSehuatangPdf error:{e}")
|
||||||
|
|
||||||
@async_job.at_times(["01:30"])
|
@async_job.at_times(["01:30"])
|
||||||
async def xiu_ren_download_task():
|
async def xiu_ren_download_task(self):
|
||||||
try:
|
try:
|
||||||
# 每天下载10组图,然后发一个帖子PDF
|
# 每天下载10组图,然后发一个帖子PDF
|
||||||
meitu_dowload_pub_pic()
|
meitu_dowload_pub_pic()
|
||||||
@@ -685,7 +685,7 @@ class Robot:
|
|||||||
self.LOG.error(f"xiu_ren_download_task error:{e}")
|
self.LOG.error(f"xiu_ren_download_task error:{e}")
|
||||||
|
|
||||||
@async_job.at_times(["09:30"])
|
@async_job.at_times(["09:30"])
|
||||||
async def generate_and_send_ranking():
|
async def generate_and_send_ranking(self):
|
||||||
try:
|
try:
|
||||||
receivers = self.gbm.get_group_list()
|
receivers = self.gbm.get_group_list()
|
||||||
if not receivers:
|
if not receivers:
|
||||||
@@ -697,7 +697,6 @@ class Robot:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.LOG.error(f"SendRanking error:{e}")
|
self.LOG.error(f"SendRanking error:{e}")
|
||||||
|
|
||||||
@async_job.at_times(["10:30"])
|
@async_job.at_times(["10:23"])
|
||||||
async def job_test():
|
async def job_test(self):
|
||||||
self.LOG.info("执行测试任务!")
|
|
||||||
await self.ipad_bot.send_text_message("Jyunere","测试任务!")
|
await self.ipad_bot.send_text_message("Jyunere","测试任务!")
|
||||||
Reference in New Issue
Block a user