-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
38 lines (26 loc) · 781 Bytes
/
utils.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
import datetime
from random import choice
import requests
import json
import keys
GREEKS = []
OCCUPATIONS = []
for f in ['greek_gods', 'greek_monsters', 'greek_titans']:
with open('names/{0}.json'.format(f)) as fp:
GREEKS += json.load(fp)[f]
with open('names/occupations.json') as f:
OCCUPATIONS = [occ.title().replace(' ', '') for occ in json.load(f)['occupations']]
def post_slack(msg):
payload = {'text': msg}
try:
requests.post(
keys.SLACK_URL,
json.dumps(payload),
headers={'content-type': 'application/json'})
except:
return True
def now():
return datetime.datetime.utcnow().isoformat()
def random_string():
name = choice(GREEKS) + "The" + choice(OCCUPATIONS)
return name