Revert "ShrinkUrl plugin, add BitLy support."

This reverts commit 147cccdf6c.

I prefer not to have APIs with authentication in Limnoria's
officiel plugins, as discussed on GH-361.
This commit is contained in:
Valentin Lorentz 2015-06-11 11:31:21 +02:00
parent d01b9b2329
commit 8b401249b8
2 changed files with 3 additions and 45 deletions

View File

@ -42,11 +42,11 @@ def configure(advanced):
conf.supybot.plugins.ShrinkUrl.shrinkSnarfer.setValue(True)
class ShrinkService(registry.OnlySomeStrings):
"""Valid values include 'tiny', 'ur1', 'x0', and 'bitly'."""
validStrings = ('tiny', 'ur1', 'x0', 'bitly')
"""Valid values include 'tiny', 'ur1', and 'x0'."""
validStrings = ('tiny', 'ur1', 'x0')
class ShrinkCycle(registry.SpaceSeparatedListOfStrings):
"""Valid values include 'ln', 'tiny', 'ur1', 'x0', and 'bitly'."""
"""Valid values include 'ln', 'tiny', 'ur1', and 'x0'."""
Value = ShrinkService
def __init__(self, *args, **kwargs):
@ -97,13 +97,4 @@ conf.registerChannelValue(ShrinkUrl, 'serviceRotation',
ShrinkCycle([], _("""If set to a non-empty value, specifies the list of
services to rotate through for the shrinkSnarfer and outFilter.""")))
conf.registerGroup(ShrinkUrl, 'bitly')
conf.registerGlobalValue(ShrinkUrl.bitly, 'login',
registry.String('', _("""Determines the API Login string used for
shortening using the Bit.ly service."""), private=True))
conf.registerGlobalValue(ShrinkUrl.bitly, 'apiKey',
registry.String('', _("""Determines the API Key string used for
shortening using the Bit.ly service."""), private=True))
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

View File

@ -255,39 +255,6 @@ class ShrinkUrl(callbacks.PluginRegexp):
irc.error(str(e))
x0 = thread(wrap(x0, ['httpUrl']))
_bitlyApi = 'http://api.bit.ly/shorten?format=txt&login=%s&apiKey=%s&longUrl=%s'
@retry
def _getbitlyUrl(self, url):
try:
return self.db.get('bitly', url)
except KeyError:
text = utils.web.getUrl(self._bitlyApi %
(self.registryValue('bitly.login'),
self.registryValue('bitly.apiKey'),
url)).decode()
if not text.startswith('http'):
raise ShrinkError(text)
self.db.set('bitly', url, text)
return text
@internationalizeDocstring
def bitly(self, irc, msg, args, url):
"""<url>
Returns an bitly version of <url>.
"""
if not (self.registryValue('bitly.login') or
self.registryValue('bitly.apiKey')):
irc.error(_("""Bit.ly Requested but login and apiKey are empty."""))
try:
bitlyurl = self._getbitlyUrl(url)
m = irc.reply(bitlyurl)
if m is not None:
m.tag('shrunken')
except ShrinkError as e:
irc.error(str(e))
bitly = thread(wrap(bitly, ['httpUrl']))
@retry
def _getExpandUrl(self, url):
url = utils.web.urlquote(url)