From 871d6858c03bcc35c43993a35bda52dba5265ad7 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 26 Aug 2003 11:39:18 +0000 Subject: [PATCH] Added an example and changed the regexp not to allow <> into the URL. --- plugins/URLSnarfer.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/plugins/URLSnarfer.py b/plugins/URLSnarfer.py index aee25477f..6bb5bc88f 100644 --- a/plugins/URLSnarfer.py +++ b/plugins/URLSnarfer.py @@ -47,6 +47,27 @@ import sqlite import privmsgs import callbacks +example = """ + lasturl, numurls, randomurl + @numurls + Error: Command must be sent in a channel or include a channel in its arguments. + (each channel has its own URL database, so these commands need to know which channel database to access) + @numurls #sourcereview + I have 93 URLs in my database. + @randomurl #sourcereview + 6: (added by Strike at 06:25 PM, August 17, 2003) + (that's the ID number, the link, and some other sundry info about it) + @lasturl + Error: Command must be sent in a channel or include a channel in its arguments. + @lasturl #sourcereview + , added by Strike at 12:12 AM, August 26, 2003. + @lasturl #sourcereview --proto ftp + , added by Strike|work at 07:27 PM, August 21, 2003. + @lasturl #sourcereview --near Stuka + , added by jemfinch at 03:16 PM, August 25, 2003. + @lasturl #sourcereview --at coderforums.com + , added by Strike|work at 02:41 PM, August 25, 2003. +""" def configure(onStart, afterConnect, advanced): # This will be called by setup.py to configure this module. onStart and @@ -82,7 +103,7 @@ class URLSnarfer(callbacks.Privmsg, ChannelDBHandler): db.commit() return db - _urlRe = re.compile(r"(\S+://\S+)", re.I) + _urlRe = re.compile(r"([^<\s]+://[^>\s]+)", re.I) def doPrivmsg(self, irc, msg): callbacks.Privmsg.doPrivmsg(self, irc, msg) channel = msg.args[0] @@ -124,7 +145,7 @@ class URLSnarfer(callbacks.Privmsg, ChannelDBHandler): (id, url, added, addedBy, _, _, _, _, _, _) = cursor.fetchone() when = time.strftime(conf.humanTimestampFormat, time.localtime(int(added))) - s = '%s: <%s> (added by %s on %s)' % (id, url, addedBy, when) + s = '%s: <%s> (added by %s at %s)' % (id, url, addedBy, when) irc.reply(msg, s) def numurls(self, irc, msg, args):