def expand(text, reply): """<url> - unshortens <url>""" args = text.split() url = args[0] try: return web.expand(url) except web.ServiceError as e: reply(e.message) raise
def gitio(text, reply): """<url> [custom] - shortens a github URL <url> using git.io with [custom] as an optional custom shortlink, or unshortens <url> if already short""" args = text.split() url = args[0] custom = args[1] if len(args) > 1 else None try: if 'git.io' in url: return web.expand(url, 'git.io') else: return web.shorten(url, custom, 'git.io') except web.ServiceError as e: reply(e.message) raise
def isgd(text, reply): """<url> [custom] - shortens a url using is.gd with [custom] as an optional custom shortlink, or unshortens <url> if already short""" args = text.split() url = args[0] custom = args[1] if len(args) > 1 else None try: if "is.gd" in url: return web.expand(url, "is.gd") else: return web.shorten(url, custom, "is.gd") except web.ServiceError as e: reply(e.message) raise