diff -r 0f96e3157b7f -r 9880bb697149 utility.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utility.py Mon Jan 19 16:42:36 2015 -0500 @@ -0,0 +1,15 @@ +import bitly_api +import irc as Irc +from configfile import Config + +def shorten_link (link): + bitly_token = Config.get_node ('bitly').get_value ('access_token', '') + + if bitly_token: + c = bitly_api.Connection (access_token = bitly_token) + try: + return c.shorten (link)['url'] + except Exception as e: + Irc.broadcast ('Error while shortening link %s: %s' % (link, e)) + + return link