From d59ac366b3d2867615906bfed55448a25b9839ac Mon Sep 17 00:00:00 2001 From: James Vega Date: Sat, 7 Mar 2009 23:46:50 -0500 Subject: [PATCH] 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 --- plugins/ShrinkUrl/config.py | 4 ++++ plugins/ShrinkUrl/plugin.py | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/ShrinkUrl/config.py b/plugins/ShrinkUrl/config.py index b0b373c37..82a9c7920 100644 --- a/plugins/ShrinkUrl/config.py +++ b/plugins/ShrinkUrl/config.py @@ -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.""")) diff --git a/plugins/ShrinkUrl/plugin.py b/plugins/ShrinkUrl/plugin.py index 2d3f6e6c1..48c408bd3 100644 --- a/plugins/ShrinkUrl/plugin.py +++ b/plugins/ShrinkUrl/plugin.py @@ -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)