-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.py
67 lines (50 loc) · 1.59 KB
/
settings.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
import json
import os
USER_TOKEN_STRING = os.environ['SLACK_USER_TOKEN_STRING']
URL_TOKEN_STRING = os.environ['SLACK_URL_TOKEN_STRING']
HASH = "%23"
class Settings:
def __init__(self):
self.settings = {}
self.reload()
def reload(self):
with open('config.json') as f:
self.settings = json.load(f)
@property
def post_url(self):
url = "https://" + self.team_domain + ".slack.com/services/hooks/slackbot"
url += "?token=" + URL_TOKEN_STRING + "&channel=" + HASH + self.channel_name
return url
@property
def is_debug(self):
return self.settings["debug"]
@property
def team_domain(self):
return self.settings["teamDomain"]
@property
def channel_name(self):
return self.settings["channelName"]
@property
def channel_id(self):
return self.settings["channelId"]
@property
def weekdays(self):
return sorted(self.settings["days"])
@property
def hours(self):
return sorted(self.settings["hours"], key=lambda hour_range: hour_range[0])
@property
def callout_min_time(self):
return self.settings["callouts"]["timeBetween"]["minTime"]
@property
def callout_max_time(self):
return self.settings["callouts"]["timeBetween"]["maxTime"]
@property
def callout_size(self):
return self.settings["callouts"]["numPeople"]
@property
def group_callout_chance(self):
return self.settings["callouts"]["groupCalloutChance"]
@property
def exercises(self):
return self.settings["exercises"]