모든 버그 해결
This commit is contained in:
parent
be4d6616f0
commit
e19aa64c8f
14 changed files with 96 additions and 31 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import re
|
||||
import json
|
||||
|
||||
def 영양정보_삭제(값:str):
|
||||
줄들 = 값.strip().split('\n')
|
||||
|
|
@ -15,13 +16,21 @@ from PIL import ImageFont
|
|||
import library.vts as vts
|
||||
import os
|
||||
|
||||
KEY = os.getenv("KEY")
|
||||
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']
|
||||
|
||||
|
||||
# DDISH_NM
|
||||
def 급식_정보_얻기(MLSV_YMD:str):
|
||||
답장 = requests.get(
|
||||
f"https://open.neis.go.kr/hub/mealServiceDietInfo?Type=json&ATPT_OFCDC_SC_CODE=E10&SD_SCHUL_CODE=7331071&MLSV_YMD={MLSV_YMD}&KEY={KEY}"
|
||||
)
|
||||
print(f"https://open.neis.go.kr/hub/mealServiceDietInfo?Type=json&ATPT_OFCDC_SC_CODE=E10&SD_SCHUL_CODE=7331071&MLSV_YMD={MLSV_YMD}&KEY={KEY}")
|
||||
print(답장.json())
|
||||
DDISH_NM = 답장.json()['mealServiceDietInfo'][1]['row'][0]['DDISH_NM']
|
||||
|
||||
return 영양정보_삭제(DDISH_NM.replace("<br/>", "\n"))
|
||||
|
|
@ -32,25 +41,26 @@ def 급식_칼로리_얻기(MLSV_YMD:str):
|
|||
)
|
||||
return 답장.json()['mealServiceDietInfo'][1]['row'][0]['CAL_INFO']
|
||||
|
||||
font = f"{os.getenv("ROOT")}library/Pretendard-Bold.ttf"
|
||||
|
||||
def 얻기(MLSV_YMD:str):
|
||||
급식 = 급식_정보_얻기(MLSV_YMD)
|
||||
print(f"{ROOT}library/skeleton.png")
|
||||
사진 = Image.open(f"{ROOT}library/skeleton.png")
|
||||
|
||||
사진 = Image.open(f'{os.getenv("ROOT")}library/skeleton.png')
|
||||
if vts.get_vts_true_or_false() == True: 사진 = Image.open(f'{os.getenv("ROOT")}library/skeleton-vts.png')
|
||||
#if vts.get_vts_true_or_false() == True: 사진 = Image.open(f'{ROOT}library/skeleton-vts.png')
|
||||
|
||||
급식_폰트 = ImageFont.truetype(font, 56)
|
||||
세부_폰트 = ImageFont.truetype(font, 24)
|
||||
|
||||
제목요소 = ImageDraw.Draw(사진)
|
||||
제목요소.text((180, 750), 급식, font=급식_폰트, fill=(255, 255, 255))
|
||||
for i, line in enumerate(reversed(급식.split('\n'))):
|
||||
제목요소.text((75, 930 - i * 60), line, font=급식_폰트, anchor="ls", fill=(255, 255, 255))
|
||||
|
||||
세부요소 = ImageDraw.Draw(사진)
|
||||
세부요소.text((560, 623), f"{MLSV_YMD[:4]}.{MLSV_YMD[4:6]}.{MLSV_YMD[6:8]}", font=세부_폰트, fill=(255, 255, 255))
|
||||
세부요소.text((540, 650), f"{급식_칼로리_얻기(MLSV_YMD)}", font=세부_폰트, fill=(137, 202, 255))
|
||||
세부요소.text((767, 80), f"{MLSV_YMD[:4]}년 {MLSV_YMD[4:6]}월 {MLSV_YMD[6:8]}일", font=세부_폰트, fill=(255, 255, 255))
|
||||
세부요소.text((825, 200), f"{급식_칼로리_얻기(MLSV_YMD)}", font=세부_폰트, fill=(137, 202, 255))
|
||||
|
||||
사진.save(f'{os.getenv("ROOT")}temp/{MLSV_YMD}.png')
|
||||
사진.save(f'{ROOT}temp/{MLSV_YMD}.png')
|
||||
|
||||
print("🍲 | Meal Info Image Saved")
|
||||
|
||||
|
|
@ -71,7 +81,7 @@ def 디스코드(MLSV_YMD:str):
|
|||
]
|
||||
|
||||
print("🏓 | Sending Payload")
|
||||
result = requests.post(os.getenv('WEBHOOK_URL'), json = data)
|
||||
result = requests.post(WEBHOOK_URL, json = data)
|
||||
print("🏓 | Payload Sent")
|
||||
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue