utility.py

Sat, 11 Apr 2015 21:02:54 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sat, 11 Apr 2015 21:02:54 +0300
changeset 122
f899af683bbe
parent 121
ac07779f788d
child 123
aeb0d0788869
permissions
-rw-r--r--

- fixed a derp in commitsdb

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

mercurial