mirror of
https://github.com/Xtao-Labs/misskey2telegram.git
synced 2024-11-22 22:05:58 +00:00
17 lines
440 B
Python
17 lines
440 B
Python
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):
|
|
if job := scheduler.get_job(f"df_{file}"):
|
|
job.remove()
|
|
scheduler.add_job(delete_file, "interval", args=[file], seconds=seconds, id=f"df_{file}")
|