Skip to content

Commit

Permalink
✨ feat: 업로더 이름 시트에 기록
Browse files Browse the repository at this point in the history
  • Loading branch information
kms0219kms committed May 4, 2024
1 parent 159900c commit 56bfd79
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Run
FROM python:3.12-slim
LABEL org.opencontainers.image.source https://github.com/kms0219kms/waklife_manager
LABEL org.opencontainers.image.source https://github.com/wakzoo-life/manager_bot

WORKDIR /usr/app
RUN apt update && apt install curl tar xz-utils git -y
Expand Down
30 changes: 22 additions & 8 deletions src/services/uploadService.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
from os.path import join

from enum import Enum
from typing import List

from discord import Attachment, Message
from discord import Message
from PIL import Image
from synology_api import filestation

Expand Down Expand Up @@ -34,7 +33,7 @@ async def upload(self, type: UploadType, message: Message) -> tuple[int, str]:
# 짤 이름만 골라서 Get
resv_zzal_names = [x.get("이름") for x in worksheet_data]

uploaded = 0
uploaded = []
errors = []

for file in message.attachments:
Expand Down Expand Up @@ -134,7 +133,20 @@ async def upload(self, type: UploadType, message: Message) -> tuple[int, str]:
)

if uploadRes == "Upload Complete":
uploaded += 1
if type != UploadType.DICT:
paths = [
x
for x in str(worksheet_data[row].get("업로더")).split(",")
if x != "0" and x != "" and x != None
]
paths.append(message.author.display_name)

uploaded.append(
{
"range": "E" + str(row + 2),
"values": [[",".join(paths)]],
}
)
else:
_error_msg = f"업로드 중 문제가 발생했습니다.\n\n{uploadRes}"

Expand All @@ -150,13 +162,15 @@ async def upload(self, type: UploadType, message: Message) -> tuple[int, str]:
if filename.endswith(".jpg") or filename.endswith(".jpeg") or filename.endswith(".png"):
os.remove(join("temp/", f"{message.author.id}_{re.sub(r'\.(jpg|jpeg|png)$', '.webp', filename)}"))

if uploaded > 0:
if uploaded == 1:
if len(uploaded) > 0:
worksheet.batch_update(uploaded)

if len(uploaded) == 1:
return (1, "")

if len(errors) >= 1:
return (uploaded, chr(10).join(errors))
return (len(uploaded), chr(10).join(errors))
else:
return (uploaded, "")
return (len(uploaded), "")
else:
raise Exception(f"업로드 중 문제가 발생했습니다.")

0 comments on commit 56bfd79

Please sign in to comment.