aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2017-04-15 02:40:34 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2017-04-15 11:57:34 +0200
commitdd8d04eb2facf3a22779740ce1a5d593a8c2a3d6 (patch)
treebdb5ca7ca3767fcee543e42a23cdb8544bd29848 /wee_slack.py
parent5e1c7e593d70972afb9a55f29d13adaf145d0166 (diff)
downloadwee-slack-dd8d04eb2facf3a22779740ce1a5d593a8c2a3d6.tar.gz
Do encode/decode in websocket and urllib calls
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 125cee2..0f202e0 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -287,7 +287,7 @@ class EventRouter(object):
"""
try:
# Read the data from the websocket associated with this team.
- data = self.teams[team_hash].ws.recv()
+ data = decode_from_utf8(self.teams[team_hash].ws.recv())
message_json = json.loads(data)
metadata = WeeSlackMetadata({
"team": team_hash,
@@ -858,7 +858,7 @@ class SlackRequest(object):
post_data["token"] = token
self.post_data = post_data
self.params = {'useragent': 'wee_slack {}'.format(SCRIPT_VERSION)}
- self.url = 'https://{}/api/{}?{}'.format(self.domain, request, urllib.urlencode(post_data))
+ self.url = 'https://{}/api/{}?{}'.format(self.domain, request, urllib.urlencode(encode_to_utf8(post_data)))
self.response_id = sha.sha("{}{}".format(self.url, self.start_time)).hexdigest()
self.retries = kwargs.get('retries', 3)
# def __repr__(self):
@@ -1053,7 +1053,7 @@ class SlackTeam(object):
try:
if expect_reply:
self.ws_replies[data["id"]] = data
- self.ws.send(message)
+ self.ws.send(encode_to_utf8(message))
dbg("Sent {}...".format(message[:100]))
except:
print "WS ERROR"