Skip to content

Instantly share code, notes, and snippets.

@BlaneyXYZ
Last active August 29, 2015 13:56
Show Gist options
  • Save BlaneyXYZ/7c54f6398dbb0f2e2a09 to your computer and use it in GitHub Desktop.
Save BlaneyXYZ/7c54f6398dbb0f2e2a09 to your computer and use it in GitHub Desktop.
Autoshorten for @TheFiZi (Now for CloudBot running on python3.4)
from cloudbot import hook
from cloudbot.util import web
import re
link_re = re.compile(r'((https?://([-\w\.]+)+(:\d+)?(/([\S/_\.]*(\?\S+)?)?)?))', re.I)
@hook.regex(link_re)
def autoshorten(match):
url = match.group(1)
try:
return web.shorten(url)
except web.ServiceError as e:
return e.message
@TheFiZi
Copy link

TheFiZi commented Mar 3, 2014

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment