summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaniel-Jones <daniel@danieljon.es>2017-07-14 10:56:15 +0930
committerdaniel-Jones <daniel@danieljon.es>2017-07-14 10:56:15 +0930
commit3f848ce2c5af2c61b16d6f225820e5c2298e7af4 (patch)
tree6f6e158b6a5aa09f63df520f3d4522382a42140b
parent0b06ff3475a454d92a0d0a009a5ebdb9ece05051 (diff)
downloadslacklog-3f848ce2c5af2c61b16d6f225820e5c2298e7af4.tar.gz
slacklog-3f848ce2c5af2c61b16d6f225820e5c2298e7af4.zip
no longer commiting utf8 encoded string
-rw-r--r--main.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/main.py b/main.py
index 9ac0848..f930004 100644
--- a/main.py
+++ b/main.py
@@ -21,9 +21,13 @@ def getjson(url):
args:
url = url to request data from
'''
- f = urllib.request.urlopen(url);
- content = f.read();
- f.close();
+ try:
+ f = urllib.request.urlopen(url);
+ content = f.read();
+ f.close();
+ except urllib.error.URLError:
+ print("error getting json, api down probably, try later");
+ raise SystemExit;
return content;
def dbconnect():
@@ -163,7 +167,7 @@ def collectbants():
print("message not logged, logging");
query = {"author": author,
"channel": j['channels'][x]['name'],
- "message": str(data['messages'][i]['text'].encode('utf8')),
+ "message": str(data['messages'][i]['text']),
"timestamp": data['messages'][i]['ts']};
message_id = messagedb.insert_one(query).inserted_id;
else: