fix a bug

This commit is contained in:
xtaodada 2022-08-02 22:22:21 +08:00
parent 4d43438a4d
commit cbbbb9c6a6
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
3 changed files with 5 additions and 4 deletions

2
ci.py
View File

@ -44,6 +44,4 @@ client = AsyncClient(timeout=10.0, headers=headers, follow_redirects=True)
# 初始化客户端 # 初始化客户端
scheduler = AsyncIOScheduler(timezone="Asia/ShangHai") scheduler = AsyncIOScheduler(timezone="Asia/ShangHai")
if not scheduler.running:
scheduler.start()
app = Client("bot", api_id=api_id, api_hash=api_hash, bot_token=bot_token, plugins={"root": "plugins"}) app = Client("bot", api_id=api_id, api_hash=api_hash, bot_token=bot_token, plugins={"root": "plugins"})

View File

@ -1,7 +1,9 @@
import logging import logging
from ci import app from ci import app, scheduler
# 日志记录 # 日志记录
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
print("Starting...") print("Starting...")
if not scheduler.running:
scheduler.start()
app.run() app.run()

View File

@ -1,5 +1,6 @@
import contextlib import contextlib
import traceback import traceback
from asyncio import sleep from asyncio import sleep
from random import uniform from random import uniform
@ -39,7 +40,7 @@ async def send_new(new: New):
return await send_new_photo(new) if new.img_urls else await send_new_text(new) return await send_new_photo(new) if new.img_urls else await send_new_text(new)
@scheduler.scheduled_job("cron", minute="*/10", id="1") @scheduler.scheduled_job("cron", minute="*/10", id="track")
async def run_every_10_minute(): async def run_every_10_minute():
news = await get_news() news = await get_news()
news = sorted(news, key=lambda x: x.publish_time, reverse=False) news = sorted(news, key=lambda x: x.publish_time, reverse=False)