import json
from instagrapi import Client
from datetime import datetime, timedelta
import library.lib as lib

with open('./config.json') as json_file:
    json_data = json.load(json_file)
    KEY = json_data['KEY']
    ROOT = json_data['ROOT']
    font = f"{ROOT}/library/Pretendard-Bold.ttf"
    WEBHOOK_URL = json_data['WEBHOOK_URL']

print("🍪 | Retrieving saved account information.")
cl = Client(json.load(open('./temp/auth/cookies.json')))
cl.set_proxy("socks5h://localhost:9999")
print("🍪 | Account information was successfully retrieved.")

오늘 = datetime.today()
내일 = 오늘 + timedelta(days=1)
MLSV_YMD = (datetime.now() + timedelta(days=1)).strftime('%Y%m%d')

print("📅 | Today is the last day of the month.")
print("📆 | Uploading School Event Post")
학사일정_경로 = lib.학사일정_얻기(MLSV_YMD)
cl.photo_upload(
    학사일정_경로,
    caption=f"#인천상정중학교 #상정중학교 #학사일정 \n{내일.strftime("%Y")}년 {내일.strftime("%m")}월 학사일정",
    extra_data={'is_paid_partnership': False}
)

print("📆 | School Event Post Uploaded")

print("🎉 | All tasks completed.")