Add URL-Shorten Module
This commit is contained in:
parent
56369049df
commit
6f54eb24ad
38
shorten.py
Normal file
38
shorten.py
Normal file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
shorten.py - URL Shorten Module
|
||||
Copyright 2013, sfan5
|
||||
"""
|
||||
import urllib
|
||||
|
||||
def shorten(phenny, input):
|
||||
arg = input.group(2)
|
||||
if not arg:
|
||||
arg = "" # Function continues and prints Help Message
|
||||
arg = arg.split(' ')
|
||||
if len(arg) < 2:
|
||||
phenny.reply("Give me an url shorten service and an address")
|
||||
return phenny.reply("Supported Services: is.gd, v.gd")
|
||||
else:
|
||||
if arg[0].lower() == "is.gd":
|
||||
p = urllib.urlencode({'format' :"simple", 'url': arg[1]})
|
||||
try:
|
||||
u = urllib.urlopen("http://is.gd/create.php?%s" % p)
|
||||
return phenny.reply(u.read())
|
||||
except:
|
||||
return phenny.reply("Problems accessing is.gd, please try a different Service")
|
||||
if arg[0].lower() == "v.gd":
|
||||
p = urllib.urlencode({'format' :"simple", 'url': arg[1]})
|
||||
try:
|
||||
u = urllib.urlopen("http://v.gd/create.php?%s" % p)
|
||||
return phenny.reply(u.read())
|
||||
except:
|
||||
return phenny.reply("Problems accessing v.gd, please try a different Service")
|
||||
return phenny.reply("Unknown Service")
|
||||
|
||||
|
||||
shorten.commands = ['shorten','sh']
|
||||
shorten.thread = True
|
||||
|
||||
if __name__ == '__main__':
|
||||
print __doc__
|
Loading…
x
Reference in New Issue
Block a user