-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimetable.py
73 lines (44 loc) · 1.97 KB
/
timetable.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
import requests
import json
import datetime
def lambda_handler(event=None, context=None):
day = datetime.datetime.today().weekday()
days_list = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
today_day = days_list[day]
Monday = ["Subject 1,", "Subject 2,", "Subject 3"]
Tuesday = ["Subject 1,", "Subject 2,", "Subject 3"]
Wednesday = ["Subject 1,", "Subject 2,", "Subject 3"]
Thursday = ["Subject 1,", "Subject 2,", "Subject 3"]
Friday = ["Subject 1,", "Subject 2,", "Subject 3"]
Saturday = ["Subject 1,", "Subject 2,", "Subject 3"]
webhook_url = 'Your-Slack-Webhook-URL'
send_data = "Good Morning Vineet!! :smile:\nToday it's " + days_list[day] + "\n\nTimetable is :"
def webhook_send():
response = requests.post(webhook_url, data=json.dumps(data), headers={'Content-Type': 'application/json'})
if (day == 0):
for i in range(len(Monday)):
send_data = send_data + " " + Monday[i]
data = { 'text': send_data }
if (day == 1):
for i in range(len(Tuesday)):
send_data = send_data + " " + Tuesday[i]
data = { 'text': send_data }
if (day == 2):
for i in range(len(Wednesday)):
send_data = send_data + " " + Wednesday[i]
data = { 'text': send_data }
if (day == 3):
for i in range(len(Thursday)):
send_data = send_data + " " + Thursday[i]
data = { 'text': send_data }
if (day == 4):
for i in range(len(Friday)):
send_data = send_data + " " + Friday[i]
data = { 'text': send_data }
if (day == 5):
for i in range(len(Saturday)):
send_data = send_data + " " + Saturday[i]
data = { 'text': send_data }
if (day == 6):
data = { 'text': 'Today is Sunday :smile: \nNo classes today. Enjoy!!!!' }
webhook_send()