ShrinkUrl: Add shrinkSnarfer.showDomain config

As requested by BeteNoire, add a config option to disable showing the domain
of the URL shrunk by the snarfer.

Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
James Vega 2009-03-07 23:46:50 -05:00
parent 2314eb4406
commit d59ac366b3
2 changed files with 12 additions and 4 deletions

View File

@ -1,5 +1,6 @@
###
# Copyright (c) 2005, Jeremiah Fincher
# Copyright (c) 2009, James Vega
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -49,6 +50,9 @@ conf.registerChannelValue(ShrinkUrl, 'shrinkSnarfer',
supybot.plugins.ShrinkUrl.minimumLength) it will post a
smaller URL from either ln-s.net or tinyurl.com, as denoted in
supybot.plugins.ShrinkUrl.default."""))
conf.registerChannelValue(ShrinkUrl.shrinkSnarfer, 'showDomain',
registry.Boolean(True, """Determines whether the snarfer will show the
domain of the URL being snarfed along with the shrunken URL."""))
conf.registerChannelValue(ShrinkUrl, 'minimumLength',
registry.PositiveInteger(48, """The minimum length a URL must be before
the bot will shrink it."""))

View File

@ -1,5 +1,6 @@
###
# Copyright (c) 2002-2004, Jeremiah Fincher
# Copyright (c) 2009, James Vega
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -132,11 +133,14 @@ class ShrinkUrl(callbacks.PluginRegexp):
if shorturl is None:
self.log.info('Couldn\'t get shorturl for %u', url)
return
domain = utils.web.getDomain(url)
if self.registryValue('bold'):
s = format('%u (at %s)', ircutils.bold(shorturl), domain)
if self.registryValue('shrinkSnarfer.showDomain', channel):
domain = ' (at %s)' % utils.web.getDomain(url)
else:
s = format('%u (at %s)', shorturl, domain)
domain = ''
if self.registryValue('bold'):
s = format('%u%s', ircutils.bold(shorturl), domain)
else:
s = format('%u%s', shorturl, domain)
m = irc.reply(s, prefixNick=False)
m.tag('shrunken')
shrinkSnarfer = urlSnarfer(shrinkSnarfer)