-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathweeklymeetup_noti_1hour_ago.py
77 lines (68 loc) · 2.38 KB
/
weeklymeetup_noti_1hour_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
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"]
PYCON_WEEKLY_DOC_URL = os.environ["PYCON_WEEKLY_DOC_URL"]
GATHERTOWN_LINK = os.environ["GATHERTOWN_LINK"]
# ZOOM_LINK = os.environ["ZOOM_LINK"]
NOW_TS = datetime.now().timestamp()
def main():
noti_1hour_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_1hour_ago():
return
if datetime.now().weekday() != 2:
print('Notify only Wednesday')
return
message = (f'{"오늘 이야기하고 싶으신 내용이 있다면"}\n'
f'{"회의록에 먼저 작성해주세요"}\n'
f'{"혹은 오늘 회의록을 먼저 읽고 참석해주세요~ :wink:"}\n'
)
slack_data = {
"username": "정기회의",
"icon_emoji": ":pyconkr:",
"channel": "#0-general",
"attachments": [
{
"fallback": "Weekly Meetup",
"color": "#9733EE",
"pretext": "<!channel> 1시간 후에 회의 시작이에요!",
"fields": [
{
"value": message,
"short": "false",
}
],
"actions": [
{
"type": "button",
"text": {
"type": "GatherTown 링크",
"text": "link",
},
"style": "primary",
"url": GATHERTOWN_LINK,
},
{
"type": "button",
"text": {
"type": ":memo: 회의록",
"text": "link",
},
"style": "primary",
"url": PYCON_WEEKLY_DOC_URL,
}
]
}
]
}
send_slack_message(slack_data)
if __name__ == '__main__':
main()