From 24d191d5dceb43d9c47019874b2c904f8b7ae076 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 1 Jan 2004 20:08:03 +0000 Subject: [PATCH] Added non-snarfing-regexp and title-snarfer-includes-url configurables. --- plugins/URL.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/URL.py b/plugins/URL.py index fa4f6d460..320e63dc8 100644 --- a/plugins/URL.py +++ b/plugins/URL.py @@ -100,7 +100,14 @@ class URL(callbacks.PrivmsgCommandAndRegexp, snarf it and offer a tinyurl replacement."""), ('title-snarfer', configurable.BoolType, False, """Determines whether the bot will output the HTML title of URLs it - sees in the channel."""),] + sees in the channel."""), + ('title-snarfer-includes-url', configurable.BoolType, True, + """Determines whether the bot will include the snarfed URL in its + title-snarfer response. This is particularly useful when people + have a habit of putting multiple URLs in a message."""), + ('non-snarfing-regexp', configurable.RegexpStrType, None, + """A regular expression that should match URLs that should not be + snarfed. Give an empty string to have no regular expression."""),] ) _titleRe = re.compile('(.*?)', re.I) maxSize = 4096 @@ -156,6 +163,9 @@ class URL(callbacks.PrivmsgCommandAndRegexp, else: text = msg.args[1] for url in self._urlRe.findall(text): + r = self.configurables.get('non-snarfing-regexp', channel) + if r and r.search(url): + continue (protocol, site, filename, _, _, _) = urlparse.urlparse(url) previousMsg = '' for oldMsg in reviter(irc.state.history): @@ -204,7 +214,9 @@ class URL(callbacks.PrivmsgCommandAndRegexp, text = webutils.getUrl(url, size=self.maxSize) m = self._titleRe.search(text) if m is not None: - s = utils.htmlToText(m.group(1).strip()) + s = 'Title: %s' % utils.htmlToText(m.group(1).strip()) + if self.configurables.get('titlesnarferincludesurl', channel): + s += ' (<%s>)' % url irc.reply(msg, 'Title: %s' % s, prefixName=False) titleSnarfer = privmsgs.urlSnarfer(titleSnarfer)