1
0
Fork 0

[framalink] Add error handling (invalid URLs)

This commit is contained in:
Max 2015-10-10 00:18:42 +01:00 committed by nemunaire
parent 5141a0dc17
commit 7ce9b2bb4c
1 changed files with 6 additions and 1 deletions

View File

@ -23,7 +23,12 @@ def framalink_reducer(url, data):
json_data = json.loads(web.getURLContent(url, "lsturl="
+ quote(data, "/:%@&=?"),
header={"Content-Type": "application/x-www-form-urlencoded"}))
return json_data['short']
if 'short' in json_data:
return json_data['short']
elif 'msg' in json_data:
raise IRCException("Error: %s" % json_data['msg'])
else:
IRCException("An error occured while shortening %s." % data)
# MODULE VARIABLES ####################################################