misskey2telegram/models/services/scheduler.py

15 lines
355 B
Python
Raw Normal View History

2022-12-22 14:18:43 +00:00
import os
from apscheduler.schedulers.asyncio import AsyncIOScheduler
scheduler = AsyncIOScheduler(timezone="Asia/ShangHai")
async def delete_file(file: str):
if os.path.exists(file):
os.remove(file)
def add_delete_file_job(file: str, seconds: int = 10 * 60):
scheduler.add_job(delete_file, "interval", args=[file], seconds=seconds)