@hook.command()
def shorten(text):
 args = text.split()
 url = args[0]
 custom = (args[1] if (len(args) > 1) else None)
 try:
  return web.shorten(url, custom=custom)
 except web.ServiceError as e:
  return e.message

@ hook . command ( ) def shorten ( text ) : args = text . split ( ) url = args [ 0 ] custom = ( args [ 1 ] if ( len ( args ) > 1 ) else None ) try : return web . shorten ( url , custom = custom ) except web . ServiceError as e : return e . message
smartly shorten a given string .