From 5200749c662e38bf07ee0a48924e2097cdc88973 Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Sat, 6 Mar 2010 12:42:59 -0700 Subject: [PATCH] revert urlhistory to non-broken version --- plugins/urlhistory.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/plugins/urlhistory.py b/plugins/urlhistory.py index cffe850..abbcc07 100644 --- a/plugins/urlhistory.py +++ b/plugins/urlhistory.py @@ -8,9 +8,6 @@ url_re = re.compile(r'([a-zA-Z]+://|www\.)[^ ]*') expiration_period = 60 * 60 * 24 # 1 day -rate_limit_period = 60 * 3 # 3 minutes -rate_limit_count = 3 - ignored_urls = [urlnorm.normalize("http://google.com")] @@ -30,21 +27,13 @@ def insert_history(db, chan, url, nick): db.commit() -def get_history_duration(db, chan, url, duration): +def get_history(db, chan, url): + db.execute("delete from urlhistory where time < ?", + (time.time() - expiration_period,)) return db.execute("select nick, time from urlhistory where " "chan=? and url=? order by time desc", (chan, url)).fetchall() -def get_history(db, chan, url): - db.execute("delete from urlhistory where time < ?", - (time.time() - duration,)) - return get_history_duration(db, chan, url, expiration_period) - - -def get_recent_links_count(db, chan, url): - return len(get_history_duration(db, chan, url, rate_limit_period)) - - def nicklist(nicks): nicks = sorted(dict(nicks), key=unicode.lower) if len(nicks) <= 2: @@ -89,7 +78,6 @@ def urlinput(inp, nick='', chan='', server='', reply=None, bot=None): url = urlnorm.normalize(m.group(0)) if url not in ignored_urls: history = get_history(db, chan, url) - recent_history = get_recent_links_count(db, chan, url) insert_history(db, chan, url, nick) - if nick not in dict(history) and recent_history < rate_limit_count: + if nick not in dict(history): return format_reply(history)