Skip to content

Commit b30aa5d

Browse files
committed
chore: 컨벤션 수정
1 parent e547348 commit b30aa5d

File tree

2 files changed

+145
-27
lines changed

2 files changed

+145
-27
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ repos:
88
rev: 24.1.1
99
hooks:
1010
- id: black
11-
args: ["--line-length", "100"]
1211

1312
- repo: https://github.com/charliermarsh/ruff-pre-commit
1413
rev: v0.2.1
1514
hooks:
1615
- id: ruff
17-
args: ["--line-length", "100"]
1816

1917
- repo: https://github.com/pre-commit/mirrors-mypy
2018
rev: v1.8.0

app/slack/contents/events.py

Lines changed: 145 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414
from app.slack.services import SlackService
1515

1616

17-
async def submit_command(ack, body, say, client, user_id: str, service: SlackService) -> None:
17+
async def submit_command(
18+
ack,
19+
body,
20+
say,
21+
client,
22+
user_id: str,
23+
service: SlackService,
24+
) -> None:
1825
"""글 제출 시작"""
1926
await ack()
2027

@@ -144,11 +151,19 @@ async def submit_command(ack, body, say, client, user_id: str, service: SlackSer
144151

145152

146153
async def submit_view(
147-
ack, body, client: AsyncWebClient, view, say, user_id: str, service: SlackService
154+
ack,
155+
body,
156+
client: AsyncWebClient,
157+
view,
158+
say,
159+
user_id: str,
160+
service: SlackService,
148161
) -> None:
149162
"""글 제출 완료"""
150163
# 슬랙 앱이 구 버전일 경우 일부 block 이 사라져 키에러가 발생할 수 있음
151-
content_url = view["state"]["values"]["content_url"]["url_text_input-action"]["value"]
164+
content_url = view["state"]["values"]["content_url"]["url_text_input-action"][
165+
"value"
166+
]
152167
channel_id = view["private_metadata"]
153168
username = body["user"]["username"]
154169

@@ -163,7 +178,9 @@ async def submit_view(
163178
await ack()
164179

165180
try:
166-
content = await service.create_submit_content(title, content_url, username, view)
181+
content = await service.create_submit_content(
182+
title, content_url, username, view
183+
)
167184
# 해당 text 는 슬랙 활동 탭에서 표시되는 메시지이며, 누가 어떤 링크를 제출했는지 확인합니다.
168185
text = f"*<@{content.user_id}>님 제출 완료.* 링크 : *<{content.content_url}|{re.sub('<|>', '', title if content.title != 'title unknown.' else content.content_url)}>*"
169186
message = await client.chat_postMessage(
@@ -244,7 +261,12 @@ async def submit_view(
244261

245262

246263
async def forward_message(
247-
ack, body, client: AsyncWebClient, view, user_id: str, service: SlackService
264+
ack,
265+
body,
266+
client: AsyncWebClient,
267+
view,
268+
user_id: str,
269+
service: SlackService,
248270
) -> None:
249271
# TODO: 방학기간에 담소에도 글을 보낼지에 대한 메시지 전송 로직
250272
await ack()
@@ -276,7 +298,14 @@ async def forward_message(
276298
)
277299

278300

279-
async def open_intro_modal(ack, body, client, view, user_id: str, service: SlackService) -> None:
301+
async def open_intro_modal(
302+
ack,
303+
body,
304+
client,
305+
view,
306+
user_id: str,
307+
service: SlackService,
308+
) -> None:
280309
"""다른 유저의 자기소개 확인"""
281310
await ack()
282311

@@ -316,7 +345,13 @@ async def open_intro_modal(ack, body, client, view, user_id: str, service: Slack
316345

317346

318347
async def edit_intro_view(
319-
ack, body, client, view, say, user_id: str, service: SlackService
348+
ack,
349+
body,
350+
client,
351+
view,
352+
say,
353+
user_id: str,
354+
service: SlackService,
320355
) -> None:
321356
"""자기소개 수정 시작"""
322357
await ack(
@@ -403,7 +438,14 @@ async def submit_intro_view(
403438
)
404439

405440

406-
async def contents_modal(ack, body, client, view, user_id: str, service: SlackService) -> None:
441+
async def contents_modal(
442+
ack,
443+
body,
444+
client,
445+
view,
446+
user_id: str,
447+
service: SlackService,
448+
) -> None:
407449
"""다른 유저의 제출한 글 목록 확인"""
408450
await ack()
409451

@@ -421,7 +463,14 @@ async def contents_modal(ack, body, client, view, user_id: str, service: SlackSe
421463
)
422464

423465

424-
async def bookmark_modal(ack, body, client, view, user_id: str, service: SlackService) -> None:
466+
async def bookmark_modal(
467+
ack,
468+
body,
469+
client,
470+
view,
471+
user_id: str,
472+
service: SlackService,
473+
) -> None:
425474
# TODO: 글 검색에서 넘어온 경우 북마크 저장 후 검색 모달로 돌아가야 함
426475
"""북마크 저장 시작"""
427476
await ack()
@@ -441,7 +490,9 @@ async def bookmark_modal(ack, body, client, view, user_id: str, service: SlackSe
441490
await client.views_open(trigger_id=body["trigger_id"], view=view)
442491

443492

444-
def get_bookmark_view(content_id: str, bookmark: models.Bookmark | None) -> dict[str, Any]:
493+
def get_bookmark_view(
494+
content_id: str, bookmark: models.Bookmark | None
495+
) -> dict[str, Any]:
445496
if bookmark is not None:
446497
# 이미 북마크가 되어 있다면 이를 사용자에게 알린다.
447498
view = {
@@ -497,7 +548,15 @@ def get_bookmark_view(content_id: str, bookmark: models.Bookmark | None) -> dict
497548
return view
498549

499550

500-
async def bookmark_view(ack, body, client, view, say, user_id: str, service: SlackService) -> None:
551+
async def bookmark_view(
552+
ack,
553+
body,
554+
client,
555+
view,
556+
say,
557+
user_id: str,
558+
service: SlackService,
559+
) -> None:
501560
"""북마크 저장 완료"""
502561
await ack()
503562

@@ -524,7 +583,14 @@ async def bookmark_view(ack, body, client, view, say, user_id: str, service: Sla
524583
)
525584

526585

527-
async def pass_command(ack, body, say, client, user_id: str, service: SlackService) -> None:
586+
async def pass_command(
587+
ack,
588+
body,
589+
say,
590+
client,
591+
user_id: str,
592+
service: SlackService,
593+
) -> None:
528594
"""글 패스 시작"""
529595
await ack()
530596

@@ -535,7 +601,15 @@ async def pass_command(ack, body, say, client, user_id: str, service: SlackServi
535601
)
536602

537603

538-
async def pass_view(ack, body, client, view, say, user_id: str, service: SlackService) -> None:
604+
async def pass_view(
605+
ack,
606+
body,
607+
client,
608+
view,
609+
say,
610+
user_id: str,
611+
service: SlackService,
612+
) -> None:
539613
"""글 패스 완료"""
540614
await ack()
541615

@@ -550,20 +624,32 @@ async def pass_view(ack, body, client, view, say, user_id: str, service: SlackSe
550624
content.ts = message.get("ts", "")
551625
await service.update_user_content(content)
552626
except Exception as e:
553-
message = (
554-
f"{service.user.name}({service.user.channel_name}) 님의 패스가 실패했어요. {str(e)}"
555-
)
627+
message = f"{service.user.name}({service.user.channel_name}) 님의 패스가 실패했어요. {str(e)}"
556628
raise BotException(message)
557629

558630

559-
async def search_command(ack, body, say, client, user_id: str, service: SlackService) -> None:
631+
async def search_command(
632+
ack,
633+
body,
634+
say,
635+
client,
636+
user_id: str,
637+
service: SlackService,
638+
) -> None:
560639
"""글 검색 시작"""
561640
await ack()
562641

563642
await service.open_search_modal(body, client)
564643

565644

566-
async def submit_search(ack, body, client, view, user_id: str, service: SlackService) -> None:
645+
async def submit_search(
646+
ack,
647+
body,
648+
client,
649+
view,
650+
user_id: str,
651+
service: SlackService,
652+
) -> None:
567653
"""글 검색 완료"""
568654
name = _get_name(body)
569655
category = _get_category(body)
@@ -588,7 +674,14 @@ async def submit_search(ack, body, client, view, user_id: str, service: SlackSer
588674
)
589675

590676

591-
async def web_search(ack, body, client, view, user_id: str, service: SlackService) -> None:
677+
async def web_search(
678+
ack,
679+
body,
680+
client,
681+
view,
682+
user_id: str,
683+
service: SlackService,
684+
) -> None:
592685
"""웹 검색 시작"""
593686
await ack()
594687

@@ -645,7 +738,14 @@ def _fetch_blocks(contents: list[models.Content]) -> list[dict[str, Any]]:
645738
return blocks
646739

647740

648-
async def back_to_search_view(ack, body, say, client, user_id: str, service: SlackService) -> None:
741+
async def back_to_search_view(
742+
ack,
743+
body,
744+
say,
745+
client,
746+
user_id: str,
747+
service: SlackService,
748+
) -> None:
649749
"""글 검색 다시 시작"""
650750
view = {
651751
"type": "modal",
@@ -776,7 +876,14 @@ def _get_keyword(body) -> str:
776876
return keyword
777877

778878

779-
async def bookmark_command(ack, body, say, client, user_id: str, service: SlackService) -> None:
879+
async def bookmark_command(
880+
ack,
881+
body,
882+
say,
883+
client,
884+
user_id: str,
885+
service: SlackService,
886+
) -> None:
780887
"""북마크 조회"""
781888
await ack()
782889

@@ -819,7 +926,12 @@ async def bookmark_command(ack, body, say, client, user_id: str, service: SlackS
819926

820927

821928
async def handle_bookmark_page(
822-
ack, body, say, client: AsyncWebClient, user_id: str, service: SlackService
929+
ack,
930+
body,
931+
say,
932+
client: AsyncWebClient,
933+
user_id: str,
934+
service: SlackService,
823935
) -> None:
824936
"""북마크 페이지 이동"""
825937
await ack()
@@ -944,7 +1056,9 @@ def _fetch_bookmark_blocks(
9441056
)
9451057

9461058
note = [
947-
bookmark.note for bookmark in bookmarks if content.content_id == bookmark.content_id
1059+
bookmark.note
1060+
for bookmark in bookmarks
1061+
if content.content_id == bookmark.content_id
9481062
][0]
9491063

9501064
blocks.append(
@@ -961,7 +1075,13 @@ def _fetch_bookmark_blocks(
9611075

9621076

9631077
async def open_overflow_action(
964-
ack, body, client, view, say, user_id: str, service: SlackService
1078+
ack,
1079+
body,
1080+
client,
1081+
view,
1082+
say,
1083+
user_id: str,
1084+
service: SlackService,
9651085
) -> None:
9661086
"""북마크 메뉴 선택"""
9671087
await ack()
@@ -1016,7 +1136,7 @@ def _get_content_metrix(
10161136

10171137
# TODO: 니즈가 확인되는 경우 활성화
10181138
# async def bookmark_search_view(
1019-
# ack, body, say, client, user_id: str, service: SlackService
1139+
# ack, body, say, client, user_id: str, service: SlackService,
10201140
# ) -> None:
10211141
# """북마크 검색 시작"""
10221142
# view = {

0 commit comments

Comments
 (0)