-
Notifications
You must be signed in to change notification settings - Fork 4
/
weeklymeetup_noti_2days_ago.py
82 lines (74 loc) · 2.84 KB
/
weeklymeetup_noti_2days_ago.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import os
import sys
import requests
from datetime import datetime
WEB_HOOK_URL = os.environ["SLACK_WEB_HOOK"]
PYCON_ICON_URL = os.environ["PYCON_ICON_URL"]
# FIXME: This url will use google api call and generate document automatically
PYCON_WEEKLY_DOC_URL = os.environ["PYCON_WEEKLY_DOC_URL"]
NOW_TS = datetime.now().timestamp()
def main():
return
noti_2day_ago()
def send_slack_message(slack_data):
byte_length = str(sys.getsizeof(slack_data))
headers = {'Content-Type': "application/json", 'Content-Length': byte_length}
response = requests.post(WEB_HOOK_URL, json=slack_data, headers=headers)
if response.status_code != 200:
raise Exception(response.status_code, response.text)
def noti_2day_ago():
if datetime.now().weekday() != 0:
print('Notify only Monday')
return
title = (f'{"모레 회의 있는 날이에요!"}')
message = (f'{":arrow_right: 참여가 가능해요 :o:"}\n'
f'{":arrow_right: 참여가 힘들어요 :x:"}\n'
f'{" "}\n'
f'{" 더불어 정기회의에서 이야기하고 싶으신 내용이 있다면"}\n'
f'{" 회의록에 먼저 작성해주세요~ :wink:"}\n'
f'{" "}\n'
)
slack_data = {
"username": "정기회의",
"icon_emoji": ":pyconkr:",
"channel": "#0-general",
"attachments": [
{
"fallback": "파준위 정기회의",
"color": "#F3DE63",
"pretext": "<!channel> 회의 참여 가능 여부를 이모지로 알려주세요~",
"author_name": "PyconKR",
"author_link": "http://pycon.kr/",
"author_icon": PYCON_ICON_URL,
# "text": "--------------------------",
# "title": ":memo: 회의록",
# "title_link": PYCON_WEEKLY_DOC_URL,
"fields": [
{
"title": title,
"value": message,
"short": "false",
}
],
"actions": [
{
"type": "button",
"text": {
"type": ":memo: 회의록",
"text": "link",
},
"style": "primary",
"url": PYCON_WEEKLY_DOC_URL,
}
],
# "image_url": "xxxxxxxxxxx", # 메시지 하단의 미리보기 image
# "thumb_url": "xxxxxxxxxxx", # title 옆에 이미지 보임
# "footer": "PyconKR",
# "footer_icon": PYCON_ICON_URL,
"ts": NOW_TS
}
]
}
send_slack_message(slack_data)
if __name__ == '__main__':
main()