-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
50 lines (35 loc) · 920 Bytes
/
main.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
import csv
import os
import random
from datetime import date
import requests
members = [
'Brian Clark',
'Sara Clark',
'Mags Magnoli'
]
roles = [
'President',
'Treasurer',
'Secretary',
]
data = {
"text": "A new officer election has been recorded!\n \n### Results:",
}
random.shuffle(members)
print(f'Results: {members}')
for i in range(len(roles)):
data['text'] += f'\n* **{roles[i]}**: {members[i]}'
today = date.today()
year = today.year
file_path = f'./results/{year}.csv'
write_header = False
if not os.path.exists(file_path):
os.makedirs(os.path.dirname(file_path), exist_ok=True)
write_header = True
with open(file_path, 'a+') as csv_file:
csv_writer = csv.writer(csv_file)
if write_header:
csv_writer.writerow(['Date'] + roles)
csv_writer.writerow([today.isoformat()] + members)
requests.post(url=os.getenv("WEBHOOK_URL"), data=data)