-
Notifications
You must be signed in to change notification settings - Fork 0
feat [geek-news-bot]: GeekNews RSS 기반 프론트엔드 뉴스 큐레이션 슬랙봇 추가 #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
59ac3c7
f196813
06f22a7
d561a96
999fdaa
4305b01
4c57a3d
c61d8f7
8578559
22700e9
0382050
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,59 +1,2 @@ | ||
| import type { ChatPostMessageArguments } from "@slack/web-api"; | ||
| import type { SlackThreadData, SlackThreadMessage } from "./types"; | ||
| import { slackClient } from "./client"; | ||
| import { getSlackThreadData, setSlackThreadData } from "./redis"; | ||
|
|
||
| export * from "./client"; | ||
| export * from "./types"; | ||
| export * from "./redis"; | ||
|
|
||
| function toChatPostMessageArgs({ channel, message }: SlackThreadMessage): ChatPostMessageArguments { | ||
| if (message.blocks !== undefined) { | ||
| return { | ||
| channel, | ||
| text: message.text, | ||
| blocks: message.blocks, | ||
| }; | ||
| } | ||
|
|
||
| return { | ||
| channel, | ||
| text: message.text, | ||
| }; | ||
| } | ||
|
|
||
| export const createSlackThread = async (id: string, _message: SlackThreadMessage) => { | ||
| try { | ||
| const response = await slackClient.chat.postMessage(toChatPostMessageArgs(_message)); | ||
|
|
||
| if (response.ok) { | ||
| const data: SlackThreadData = { | ||
| id, | ||
| version: 1, | ||
| channel: response.channel ?? _message.channel, | ||
| thread_ts: response.ts ?? "", | ||
| }; | ||
| await setSlackThreadData(id, data, _message.ex ? { ex: _message.ex } : undefined); | ||
|
|
||
| return data; | ||
| } | ||
|
|
||
| return null; | ||
| } catch (error) { | ||
| console.error(error); | ||
| return null; | ||
| } | ||
| }; | ||
|
|
||
| export const findSlackThread = async (id: string) => { | ||
| try { | ||
| const data = await getSlackThreadData(id); | ||
|
|
||
| if (data) { | ||
| return data; | ||
| } | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| return null; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import type { SlackThreadMessage } from "./types"; | ||
| import { slackClient } from "./client"; | ||
| import { setSlackThreadData, getSlackThreadData } from "./redis"; | ||
| import type { SlackThreadData } from "./types"; | ||
|
|
||
| function toChatPostMessageArgs({ channel, message }: SlackThreadMessage) { | ||
| if (message.blocks !== undefined) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제가 머리가 나빠서 그런가... message의 blocks 값이 undefined가 아니라는건 어떤 의미인가요? |
||
| return { | ||
| channel, | ||
| text: message.text, | ||
| blocks: message.blocks, | ||
| }; | ||
| } | ||
|
|
||
| return { | ||
| channel, | ||
| text: message.text, | ||
| }; | ||
| } | ||
|
|
||
| export const createSlackThread = async (id: string, _message: SlackThreadMessage) => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 보통 언더바는 안쓰는 값이라는 암묵적인 뜻이 있는 걸로 아는데, _message에 언더바가 붙은 이유는 뭔가여? |
||
| try { | ||
| const response = await slackClient.chat.postMessage(toChatPostMessageArgs(_message)); | ||
|
|
||
| if (response.ok) { | ||
| const data: SlackThreadData = { | ||
| id, | ||
| version: 1, | ||
| channel: response.channel ?? _message.channel, | ||
| thread_ts: response.ts ?? "", | ||
| }; | ||
| await setSlackThreadData(id, data, _message.ex ? { ex: _message.ex } : undefined); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. redis instance에 저장하고 끝인가요?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 리뷰하면서 이해완료했슴니다 ㅎㅎ |
||
|
|
||
| return data; | ||
| } | ||
|
|
||
| return null; | ||
| } catch (error) { | ||
| console.error(error); | ||
| return null; | ||
| } | ||
| }; | ||
|
|
||
| export const findSlackThread = async (id: string) => { | ||
| try { | ||
| const data = await getSlackThreadData(id); | ||
|
|
||
| if (data) { | ||
| return data; | ||
| } | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| return null; | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 베럴파일의 존재이유가 뭔가요? client.ts도 따로 export하고, thread.ts도 따로 export해주는거 같아서요!
여기서 types랑 redis만 관리하는 이유가 있을까요?