[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

View File

@ -23,7 +23,12 @@ def framalink_reducer(url, data):
json_data = json.loads(web.getURLContent(url, "lsturl=" json_data = json.loads(web.getURLContent(url, "lsturl="
+ quote(data, "/:%@&=?"), + quote(data, "/:%@&=?"),
header={"Content-Type": "application/x-www-form-urlencoded"})) header={"Content-Type": "application/x-www-form-urlencoded"}))
if 'short' in json_data:
return json_data['short'] 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 #################################################### # MODULE VARIABLES ####################################################