utility.py

changeset 120
9880bb697149
child 121
ac07779f788d
equal deleted inserted replaced
119:0f96e3157b7f 120:9880bb697149
1 import bitly_api
2 import irc as Irc
3 from configfile import Config
4
5 def shorten_link (link):
6 bitly_token = Config.get_node ('bitly').get_value ('access_token', '')
7
8 if bitly_token:
9 c = bitly_api.Connection (access_token = bitly_token)
10 try:
11 return c.shorten (link)['url']
12 except Exception as e:
13 Irc.broadcast ('Error while shortening link %s: %s' % (link, e))
14
15 return link

mercurial